I get the following error: Invalid query: 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 'ORDER BY f_dateadded DESC' at line 1 I don't know what I'm doing wrong. Could someone please look at the code below. I'm using GoDaddy hosting and getting the error. Thanks for any help you could offer. <? $conn=mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname) or die ("Unable to connect to MySQL"); // print "Connected to MySQL"; $qresult2 = mysql_query("SELECT * FROM t_favs WHERE u_id=$userID ORDER BY f_dateadded DESC"); if (!$qresult2) { die('Invalid query: ' . mysql_error()); } while ($line2 = mysql_fetch_assoc($qresult2)){ $qresult = mysql_query("SELECT * FROM t_media WHERE m_id=".$line2["m_id"]." ORDER BY m_id DESC LIMIT 1"); if (!$qresult) { die('Invalid query: ' . mysql_error()); } while ($line = mysql_fetch_assoc($qresult)){ ?> <? include("showitem.php"); ?> <? } } mysql_close($conn); ?> PHP:
My guess is this line: You probably want to look like: $qresult2 = mysql_query("SELECT * FROM t_favs WHERE u_id=".$userID." ORDER BY f_dateadded DESC"); PHP: So that the $userID is actually parsed.
You can do it like, mysql_query("SELECT * FROM `table` WHERE u_id = '$id' ORDER BY f_dateadded DESC") or die (mysql_error()); PHP:
Hi Zybon, I tried that but same error sunny, the database is 4.1 but in godaddy phpinfo, i see client api 5.x.x
Does $userID actually have a value before it is being used in that query? I assumed so, but if that code is everything in the script, that's probably the issue.
well, it checks whether the use is logged in and if not, they get to signup page. this is the website: metropolizonline [dot] com and when you click on myaccount, you will see this error.
OK, try this: $qresult2 = mysql_query("SELECT * FROM t_favs WHERE u_id='$userID' ORDER BY f_dateadded DESC" If the error goes away, then you have a code bug. The variable "$userID" is empty or undefined, which without the ' marks surrounding the variable will cause an error. This code probably won;t work right, but the SQL error will be gone. Also, check the spelling and capitalization of "f_dateadded" on the line to make sure it is correct. PM me if you need more info.
well the error is gone but blank page now...i installed the script on my server and it worked fine...it is working on pokerfinder dot com but on godaddy it wont work...i think its php and mysql version conflict.
where did you get $userID from? is it passed by form? is the status of register_global on the php.ini between your old and new server the same?