Jump to content

Recommended Posts

Posted

I get this error when trying to retreive data on one of my pages:

 

"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"

 

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!!!

Posted

Here's a copy & paste of my code:

 

$Query = "select * from cd_review where cd_id = $article";

$Result = mysql_query($Query,$Link) or die("Error when querying the database: ".mysql_error());

 

if(mysql_num_rows($Result) == 0) {

print("No results to display.");

}

 

while ($Row = mysql_fetch_array($Result)) {

print("<font size=5><i>$Row[title]</i></font><p>");

print("$Row[review]");

}

 

mysql_close($Link);

 

It's the same as my other pages, except the table name is different.

Posted

I can't find anything... 2 suggestions:

 

1) Take out the spaces before and after the = equal sign in the query.

2) Put a space between the 2 arguments to the mysql_query() function.

Posted
$Query = "select * from cd_review where cd_id = $article";

$Result = mysql_query($Query,$Link) or die("Error when querying the database: ".mysql_error());

Another thing I would be checking is the contents of $article.

Posted (edited)

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.

 

Try adding a bit more of error checking to the mysql_query() line, like this:

>$Result = mysql_query($Query,$Link) or die("Query: $Query<br /><br />Error when querying the database: ".mysql_error());

 

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.

 

Hope it helps ;)

Edited by TCH-Raul
Posted

Hey y'all,

 

I'm still having problems.... (I've been away for the past few days btw)...

 

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?

Posted

Ok, here's what I'm trying to do.... go to http://www.starryconstellation.com, 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:

 

$Query = "select * from cd_review where cd_id = $article";

 

and then displays the info... but somehow, it doesn't read the $article!!

 

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!

Posted

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.

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:

 

$Query = "select * from cd_review where cd_id = $article";

Shouldn't the arguments be the same? Either ....php?article=9 or ... cd_id=$artist

 

My 2p. Hope it helps. :)

Jim

Posted

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?!?! :) ;) :)

 

Thanks for noticing that! Appreciate it a lot! :) Rock Sign

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...