Kieran-R Posted November 6, 2010 Posted November 6, 2010 Hello. Im having a problem with one of my MySQL querys, but I fail to understand where the error is! Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home3/mafianat/public_html/parse_comments.php on line 13 Line 13 = $Query = mysql_query("SELECT * FROM `comments` WHERE `userID` = ".$_GET['u']." ORDER BY `commentID` DESC LIMIT 5", $c); To me, that query looks fine... Can someone please assist me here? Thanks! Quote
a_bertrand Posted November 6, 2010 Posted November 6, 2010 are you sure $c is your connection and that it is open before trying to execute the query? A common error is to forget to include the PHP files which open the connections (like global.php for mccodes) Quote
Dayo Posted November 6, 2010 Posted November 6, 2010 try removing the , $c and change `userID` = ".$_GET['u']." to `userID` = ".abs(intval($_GET['u']))." Quote
Kieran-R Posted November 6, 2010 Author Posted November 6, 2010 @ Dayo: Still same error :( I am using V.2, and the only file that is being included is config.php. Globals is not needed in this file as its included in another file with globals. Quote
Djkanna Posted November 6, 2010 Posted November 6, 2010 If your only using the config.php you need to include the class then configure it as $c will be undefined. Quote
Kieran-R Posted November 6, 2010 Author Posted November 6, 2010 ahh right. But when I remove the $c, then its saying it cant connect to the db... Quote
Dominion Posted November 6, 2010 Posted November 6, 2010 I think config.php does not connect to the database in v2. take the include out and add a mysql_connect() should then work. you could also just use something more like the mysql.php file thats in lite/v1. Quote
Spudinski Posted November 6, 2010 Posted November 6, 2010 It's could be a bunch of things, either the table/column does not exist. OR The connection might be faulty - as mentioned before. Try using your own parameters first, the basic "mysql_connect". <?php $c = mysql_connect(server, user, passwd): mysql_selectdb('db', $c); {... and then your query ...} ?> Or just include the globals.php file. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.