I get this error when trying to retreive data on one of my pages: <br /><br /><!--coloro:red--><span style="color:red"><!--/coloro-->"Error when querying the database: 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 '' at line 1"<!--colorc--></span><!--/colorc--><br /><br />I don't get why this happening, cause it works on my other pages, and the php code structure is EXACTLY the same too! I'm guessing it has something to do with my sql table. Please help. Mad!!!<!--content-->
Deno, what's the SQL query you're trying to execute?<!--content-->
Here's a copy & paste of my code: <br /><br /><!--sizeo:1--><span style="font-size:8pt;line-height:100%"><!--/sizeo--><!--coloro:blue--><span style="color:blue"><!--/coloro-->$Query = "select * from cd_review where cd_id = $article";<br />$Result = mysql_query($Query,$Link) or die("Error when querying the database: ".mysql_error());<br /><br />if(mysql_num_rows($Result) == 0) {<br /> print("No results to display.");<br />} <br /><br />while ($Row = mysql_fetch_array($Result)) {<br />print("<font size=5><i>$Row[title]</i></font><p>");<br />print("$Row[review]");<br />}<br /><br />mysql_close($Link);<!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><br /><br />It's the same as my other pages, except the table name is different.<!--content-->
I can't find anything... 2 suggestions:<br /><br />1) Take out the spaces before and after the = equal sign in the query.<br />2) Put a space between the 2 arguments to the mysql_query() function.<!--content-->
<!--QuoteBegin-Deno+Apr 11 2004, 10:30 PM--><div class='quotetop'>QUOTE(Deno @ Apr 11 2004, 10:30 PM)</div><div class='quotemain'><!--QuoteEBegin--><!--sizeo:1--><span style="font-size:8pt;line-height:100%"><!--/sizeo--><!--coloro:blue--><span style="color:blue"><!--/coloro-->$Query = "select * from cd_review where cd_id = $article";<br />$Result = mysql_query($Query,$Link) or die("Error when querying the database: ".mysql_error());<!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><!--QuoteEnd--></div><!--QuoteEEnd--><br />Another thing I would be checking is the contents of <!--coloro:blue--><span style="color:blue"><!--/coloro-->$article<!--colorc--></span><!--/colorc-->.<!--content-->
Yep, I agree with Mike, that's probably where the problem is, because that's the only part of the query that we can't see in it's final form. Other than that, I don't see any error. I prefer to use all caps for the SQL statements but I don't think it makes a difference.<br /><br />Try adding a bit more of error checking to the mysql_query() line, like this: <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$Result = mysql_query($Query,$Link) or die("Query: $Query<br /><br />Error when querying the database: ".mysql_error());<!--c2--></div><!--ec2--><br /><br />That way you'll be able to see the whole query and check that $article variable to see if it's ruining the whole thing.<br /><br />Hope it helps <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Hey y'all, <br /><br />I'm still having problems.... (I've been away for the past few days btw)...<br /><br />I decided to give it a test, by printing the $article variable to see if it even carried the $article number over, and it prints nothing on the next page. What's my problem?<!--content-->
Ok, here's what I'm trying to do.... go to <a href="http://www.starryconstellation.com" target="_blank">http://www.starryconstellation.com</a>, then scroll down to the links that say "CD Review" under Jennifer Marks or Ben Arthur. When you click on those links, it goes to the cdreview.php page, looking like this cdreview.php?artist=9 or 10. It goes to the sql db and queries this: <br /><br />$Query = "select * from cd_review where cd_id = $article";<br /><br />and then displays the info... but somehow, it doesn't read the $article!! <br /><br />But yet it works on the rest of my pages, like the TV and movie reviews. The code's EXACTLY the same!! please please help!<!--content-->
This may be ridiculously simple, or maybe I'm just missing something (entirely possible), but it seems to me that you're passing the wrong variable name to the .php page.<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->it goes to the cdreview.php page, looking like this cdreview.php?artist=9 or 10. It goes to the sql db and queries this:<br /><br />$Query = "select * from cd_review where cd_id = $article";<!--QuoteEnd--></div><!--QuoteEEnd--><br />Shouldn't the arguments be the same? Either <b>....php?article=9</b> or <b>... cd_id=$artist</b><br /><br />My 2p. Hope it helps. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /> <br />Jim<!--content-->
You know what Jim? You are sooooo right! ARRRGHHH!! How stupid of me! getting $artist and $article mixed up!! man, how can I not see that?!?! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /> <br /><br />Thanks for noticing that! Appreciate it a lot! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /> Rock Sign<!--content-->
Deno, what's the SQL query you're trying to execute?<!--content-->
Here's a copy & paste of my code: <br /><br /><!--sizeo:1--><span style="font-size:8pt;line-height:100%"><!--/sizeo--><!--coloro:blue--><span style="color:blue"><!--/coloro-->$Query = "select * from cd_review where cd_id = $article";<br />$Result = mysql_query($Query,$Link) or die("Error when querying the database: ".mysql_error());<br /><br />if(mysql_num_rows($Result) == 0) {<br /> print("No results to display.");<br />} <br /><br />while ($Row = mysql_fetch_array($Result)) {<br />print("<font size=5><i>$Row[title]</i></font><p>");<br />print("$Row[review]");<br />}<br /><br />mysql_close($Link);<!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><br /><br />It's the same as my other pages, except the table name is different.<!--content-->
I can't find anything... 2 suggestions:<br /><br />1) Take out the spaces before and after the = equal sign in the query.<br />2) Put a space between the 2 arguments to the mysql_query() function.<!--content-->
<!--QuoteBegin-Deno+Apr 11 2004, 10:30 PM--><div class='quotetop'>QUOTE(Deno @ Apr 11 2004, 10:30 PM)</div><div class='quotemain'><!--QuoteEBegin--><!--sizeo:1--><span style="font-size:8pt;line-height:100%"><!--/sizeo--><!--coloro:blue--><span style="color:blue"><!--/coloro-->$Query = "select * from cd_review where cd_id = $article";<br />$Result = mysql_query($Query,$Link) or die("Error when querying the database: ".mysql_error());<!--sizec--></span><!--/sizec--><!--colorc--></span><!--/colorc--><!--QuoteEnd--></div><!--QuoteEEnd--><br />Another thing I would be checking is the contents of <!--coloro:blue--><span style="color:blue"><!--/coloro-->$article<!--colorc--></span><!--/colorc-->.<!--content-->
Yep, I agree with Mike, that's probably where the problem is, because that's the only part of the query that we can't see in it's final form. Other than that, I don't see any error. I prefer to use all caps for the SQL statements but I don't think it makes a difference.<br /><br />Try adding a bit more of error checking to the mysql_query() line, like this: <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->$Result = mysql_query($Query,$Link) or die("Query: $Query<br /><br />Error when querying the database: ".mysql_error());<!--c2--></div><!--ec2--><br /><br />That way you'll be able to see the whole query and check that $article variable to see if it's ruining the whole thing.<br /><br />Hope it helps <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /><!--content-->
Hey y'all, <br /><br />I'm still having problems.... (I've been away for the past few days btw)...<br /><br />I decided to give it a test, by printing the $article variable to see if it even carried the $article number over, and it prints nothing on the next page. What's my problem?<!--content-->
Ok, here's what I'm trying to do.... go to <a href="http://www.starryconstellation.com" target="_blank">http://www.starryconstellation.com</a>, then scroll down to the links that say "CD Review" under Jennifer Marks or Ben Arthur. When you click on those links, it goes to the cdreview.php page, looking like this cdreview.php?artist=9 or 10. It goes to the sql db and queries this: <br /><br />$Query = "select * from cd_review where cd_id = $article";<br /><br />and then displays the info... but somehow, it doesn't read the $article!! <br /><br />But yet it works on the rest of my pages, like the TV and movie reviews. The code's EXACTLY the same!! please please help!<!--content-->
This may be ridiculously simple, or maybe I'm just missing something (entirely possible), but it seems to me that you're passing the wrong variable name to the .php page.<!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->it goes to the cdreview.php page, looking like this cdreview.php?artist=9 or 10. It goes to the sql db and queries this:<br /><br />$Query = "select * from cd_review where cd_id = $article";<!--QuoteEnd--></div><!--QuoteEEnd--><br />Shouldn't the arguments be the same? Either <b>....php?article=9</b> or <b>... cd_id=$artist</b><br /><br />My 2p. Hope it helps. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /> <br />Jim<!--content-->
You know what Jim? You are sooooo right! ARRRGHHH!! How stupid of me! getting $artist and $article mixed up!! man, how can I not see that?!?! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/tongue.gif" style="vertical-align:middle" emoid="" border="0" alt="tongue.gif" /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /> <br /><br />Thanks for noticing that! Appreciate it a lot! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid="" border="0" alt="smile.gif" /> Rock Sign<!--content-->