so um das mal etwas voran zu treiben hier mein Interface das ich zum laufen bringen möchte:
- Code: Select all
<?php
$DBIP = 'localhost';
$DBUser = 'root';
$DBPasswort = '';
/* connect to the db */
$link = mysql_connect($DBIP,$DBUser,$DBPasswort) or die('Cannot connect to the DB');
mysql_select_db('CO2',$link) or die('Cannot select the DB');
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET 'utf8'");
$method = $_GET['method'];
switch($method)
{
case "GetEAN":
$EAN = $_GET['EAN'];
$ART = $_GET['ART'];
$query = mysql_query("
SELECT Produktname, CO2
FROM Produkt
Where Code ='".$EAN."' AND Codeart ='".$ART."'
");
output($query);
break;
case "GetEANS":
$query = mysql_query("
SELECT Produktname, CO2
FROM Produkt
");
output($query);
break;
default:
$query = mysql_query("
SELECT Produktname, CO2
FROM Produkt
");
output($query);
break;
}
function input($eintragen)
{
if($eintragen == true)
{
echo "Eintrag war erfolgreich";
}
else
{
echo mysql_error();
}
}
function output($query)
{
$rows = array();
while($r = mysql_fetch_assoc($query))
{
$rows[] = $r;
}
print json_encode($rows);
}
?>
im normalen Netzwerk funktioniert das auch das mir meine Datenbank den passenden Eintrag liefert. Wenn ich allerdings aus dem Netz darauf zugreifen will erscheint
Notice: Undefined index: method in C:\xampp\htdocs\index.php on line 11
Ich rufe das über
http://localhost/index.php?method=GetEAN&EAN=5449000017956&ART=EAN_13
auf und ansonsten halt den localhost durch die ddns Adresse ersetzt
falls ihr noch etwas von mir braucht schreibt mir was ihr braucht.
Vielen Dank schonmal