MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 31st, 2005, 01:24 PM
Usalabs Usalabs is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 Usalabs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 37 sec
Reputation Power: 0
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");
#===================
?>

Reply With Quote
  #2  
Old July 31st, 2005, 03:06 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
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"


Reply With Quote
  #3  
Old July 31st, 2005, 04:50 PM
Usalabs Usalabs is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 3 Usalabs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 37 sec
Reputation Power: 0
Quote:
Originally Posted by Madpawn
Looks like $RequestID isn't being set correctly. Your error is coming from that missing value.


$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);

Reply With Quote
  #4  
Old July 31st, 2005, 05:11 PM
Madpawn Madpawn is offline
My beat is correct.
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 339 Madpawn User rank is Private First Class (20 - 50 Reputation Level)Madpawn User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 3 m 33 sec
Reputation Power: 4
Should it be $queue['RequestID'] instead of $mainsong['RequestID'], then?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > What is the correct syntax to prevent error 1064?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT