mysql_query Problem
JuraX
- datenbank
Hi,
ich habe ein Problem mit mysql query und variablen:
$connection=mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
mysql_select_db($mysqldb, $connection) or die("Konnte die Datenbank $mysqldb nicht waehlen.");
$sql = 'UPDATE [online-hiorg].[alert]
SET
`id` = "1"
`wache` = "{$wache}"
`fahrzeuge` = "{$fahrzeug}"
`strasse` = "{$strase}"
`plz` = "{$plz}"
`ort` = "{$ort}"
`fon` = "{fon}"
`stichwort` = "{$stichwort}"
`object` = "{$objekt}"
`mitteiler` = "{$mitvon}"
`masnahme` = "{$masnahme}"
`kommentar` = "{$kommentar}"
WHERE `alert`.`id` = 1 LIMIT 1';
$adressen_query = mysql_query($sql) or die(mysql_error());
Er springt leider immer auf die mit folgender aussage:
<<< You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[online-hiorg].[alert] SET id
= "1" wache
= "{$wache}" ' at line 1 >>>
Kann mir jmd sagen , wie ich es richtig machen kann?
Hi JuraX!
<<< You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[online-hiorg].[alert] SET
id
= "1"wache
= "{$wache}" ' at line 1 >>>Kann mir jmd sagen , wie ich es richtig machen kann?
Du musst Kommas zwischen die einzelnen Zuweisungen setzen.
mfG
Benjamin
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[online-hiorg].[alert] SET id
= "1", wache
= "{$wache}"' at line 1
$connection=mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
mysql_select_db($mysqldb, $connection) or die("Konnte die Datenbank $mysqldb nicht waehlen.");
$sql = 'UPDATE [online-hiorg].[alert]
SET
`id` = "1",
`wache` = "{$wache}",
`fahrzeuge` = "{$fahrzeug}",
`strasse` = "{$strase}",
`plz` = "{$plz}",
`ort` = "{$ort}",
`fon` = "{fon}",
`stichwort` = "{$stichwort}",
`object` = "{$objekt}",
`mitteiler` = "{$mitvon}",
`masnahme` = "{$masnahme}",
`kommentar` = "{$kommentar}",
WHERE `alert`.`id` = 1 LIMIT 1';
$adressen_query = mysql_query($sql) or die(mysql_error());
leider nicht...
leider nicht...
Sei doch so nett und mach dir eine Debug-Ausgabe des eigentlichen SQL-Statements.
wie?
das ist die Ausgabe:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[online-hiorg].[alert] SET
id
= "1",wache
= "{$wache}"' at line 1
wie?
ich würd's einfach mit echo $sql;
versuchen ...
ich habs schon!
$sql = "UPDATE `online-hiorg`.`alert`
SET
`plz` = '{$plz}',
`ort` = '{$ort}',
`fon` = '{$fon}',
`stichwort` = '{$stichwort}',
`object` = '{$objekt}',
`mitteiler` = '{$mitvon}',
`masnahme` = '{$masnahme} ',
`kommentar` = '{$kommentar}',
`strasse` = '{$strasse}',
`wache` = '{$wache}',
`fahrzeuge` = '{$fahrzeug}'
WHERE `alert`.`id` =1 LIMIT 1";
Hi!
ich habs schon!
$sql = "UPDATE online-hiorg
.alert
SET
plz
= '{$plz}',
ort
= '{$ort}',
fon
= '{$fon}',
stichwort
= '{$stichwort}',
object
= '{$objekt}',
mitteiler
= '{$mitvon}',
masnahme
= '{$masnahme} ',
kommentar
= '{$kommentar}',
strasse
= '{$strasse}',
wache
= '{$wache}',
fahrzeuge
= '{$fahrzeug}'WHERE
alert
.id
=1 LIMIT 1";
Das ist schonmal die halbe Miete. Und nun noch statt der geschweiften Klammern den [Kontextwechsel](http://aktuell.de.selfhtml.org/artikel/php/kontextwechsel/) beachten.
Lo!
Hi!
$sql = 'UPDATE [online-hiorg].[alert]
Verwende lieber MSQL-Syntax und nicht die von MS-SQL. Auskünfte dazu gibt das Manual, zum Beispiel dort: http://dev.mysql.com/doc/refman/5.1/en/identifiers.html.
Lo!