Een error die er niet hoort
Ik ben bezig met een software. Topics sticky-en werkt wel, maar wanneer ik met hetzelfde script (alleen namen anders) topics probeer te sluiten, krijg ik dit:
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 'lock= 1 WHERE id='11'' at line 1
Dit is de code die het updated:
Code (php)
1
mysql_query("UPDATE ".$database['prefix']."topics SET lock= 1 WHERE id='".$_GET['topic']."'") or die (mysql_error());
Weet iemand wat er fout is (MySQL is weer zo handig om me niet te vertellen WAT nu de fout is -_-)?
zet de 1 tussen ''? dus lock='1'
Tobias Witmer op 20/02/2011 16:06:54:
zet de 1 tussen ''? dus lock='1'
Gedaan, maar helpt niet. :( Het rare is, met het andere script werkt het wel gewoon. Dit is het sticky script:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
global $database;
$pintopic = mysql_query("SELECT * FROM ".$database['prefix']."topics WHERE id='".$_GET['topic']."'");
while($pin = mysql_fetch_array($pintopic)) {
if($pin['pin'] == 1)
{
mysql_query("UPDATE ".$database['prefix']."topics SET pin= 0 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
else
{
mysql_query("UPDATE ".$database['prefix']."topics SET pin= 1 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
}
header("Location: index.php?topic=".$_GET['topic']);
$pintopic = mysql_query("SELECT * FROM ".$database['prefix']."topics WHERE id='".$_GET['topic']."'");
while($pin = mysql_fetch_array($pintopic)) {
if($pin['pin'] == 1)
{
mysql_query("UPDATE ".$database['prefix']."topics SET pin= 0 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
else
{
mysql_query("UPDATE ".$database['prefix']."topics SET pin= 1 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
}
header("Location: index.php?topic=".$_GET['topic']);
En dit die van het slotje (net weer hersteld :P)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
global $database;
$locktopic = mysql_query("SELECT * FROM ".$database['prefix']."topics WHERE id='".$_GET['topic']."'");
while($lock = mysql_fetch_array($locktopic)) {
if($lock['lock'] == 1)
{
mysql_query("UPDATE ".$database['prefix']."topics SET lock= 0 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
else
{
mysql_query("UPDATE ".$database['prefix']."topics SET lock= 1 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
}
header("Location: index.php?topic=".$_GET['topic']);
$locktopic = mysql_query("SELECT * FROM ".$database['prefix']."topics WHERE id='".$_GET['topic']."'");
while($lock = mysql_fetch_array($locktopic)) {
if($lock['lock'] == 1)
{
mysql_query("UPDATE ".$database['prefix']."topics SET lock= 0 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
else
{
mysql_query("UPDATE ".$database['prefix']."topics SET lock= 1 WHERE id='".$_GET['topic']."'") or die (mysql_error());
}
}
header("Location: index.php?topic=".$_GET['topic']);
Robert Monden op 20/02/2011 15:57:53:
... the right syntax to use near 'lock= 1 WHERE id='11'' at line 1
Lock is een reserved word. Niet gebruiken dus.
- SanThe - op 20/02/2011 16:25:12:
Lock is een reserved word. Niet gebruiken dus.
Veranderd en het werkt :D Bedankt, iedereen :) Solved