|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
What is the correct syntax to prevent error 1064?
I have mysql version 4.1 and have no problems with accessing the other databases I have setup, but there's one database, that I can't query, the line below is used:-
$db->open("SELECT * FROM requestlist WHERE (ID = $requestID) LIMIT 1"); But when that line is reached, I get:- status=err SQL error=1064 SQL error string=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 ') LIMIT 1' at line 2 SQL=SELECT * FROM requestlist WHERE (ID = ) LIMIT 1 what is the right syntax? The full line of the code is:- <? #################### # Request Dedication $requestID = $mainsong['requestID']; $db->open("SELECT * FROM requestlist WHERE (ID = $requestID) LIMIT 1"); if(($info = $db->row()) and (!empty($info['message']))) require("dedication.php"); #=================== ?> |
|
#2
|
|||
|
|||
|
Looks like $RequestID isn't being set correctly. Your error is coming from that missing value.
__________________
"A pawn is the most important piece on the chessboard -- to a pawn" |
|
#3
|
|||
|
|||
|
Quote:
$requestID is set higher up in the script, the lines below are the beginning of the script. $db->open("SELECT songlist.*, historylist.listeners as listeners, historylist.requestID as requestID, historylist.date_played as starttime FROM historylist,songlist WHERE (historylist.songID = songlist.ID) AND (songlist.songtype='S') ORDER BY historylist.date_played DESC LIMIT 6"); $history = $db->rows(); reset($history); $db->open("SELECT songlist.*, queuelist.requestID as requestID FROM queuelist, songlist WHERE (queuelist.songID = songlist.ID) AND (songlist.songtype='S') AND (songlist.artist <> '') ORDER BY queuelist.sortID ASC LIMIT 2"); $queue = $db->rows(); reset($queue); |
|
#4
|
|||
|
|||
|
Should it be $queue['RequestID'] instead of $mainsong['RequestID'], then?
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > What is the correct syntax to prevent error 1064? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|