L Posted November 11, 2007 Share Posted November 11, 2007 Hey, I've been searching the forums and nothing has seemed to help me. Basically I get this error Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home2/iffatb/public_html/iv/forums/includes/fhead.php on line 45 line 45 is $numberposts1=mysql_query("SELECT * FROM `posts` WHERE `by`='".$_SESSION['username']."'", $conn1) or die(mysql_error()); Before that I have a require to my database connection(which is properly connecting since I checked for errors and nothing showed up). Annd after that I am counting the rows from the query to decide what the rank of the person is... $numposts1=mysql_num_rows($numberposts1); thank you for all the help...I'm sorry if I overlooked something while searching but this has been bothering me for a while now and I just can't get it to work! Link to comment https://forums.phpfreaks.com/topic/76867-solved-query-not-a-supplied-arguement/ Share on other sites More sharing options...
wildteen88 Posted November 11, 2007 Share Posted November 11, 2007 That error is referring to the second parameter in the mysql_query function (highlighted below): $numberposts1=mysql_query("SELECT * FROM `posts` WHERE `by`='".$_SESSION['username']."'", $conn1) or die(mysql_error()); The second parameter to the mysql_query function is an optional parameter, but is reserved for passing the link resource from a connection to mysql via mysql_connect. Where does the $conn1 variable get set to? Link to comment https://forums.phpfreaks.com/topic/76867-solved-query-not-a-supplied-arguement/#findComment-389180 Share on other sites More sharing options...
L Posted November 11, 2007 Author Share Posted November 11, 2007 It gets sent to my second database which deals with my forums... I have a database for my main website(pms, users, comments, news) and one for my forums(topics, posts, threads, etc) Link to comment https://forums.phpfreaks.com/topic/76867-solved-query-not-a-supplied-arguement/#findComment-389181 Share on other sites More sharing options...
L Posted November 11, 2007 Author Share Posted November 11, 2007 Can anyone else help me??? I am at a wall! Link to comment https://forums.phpfreaks.com/topic/76867-solved-query-not-a-supplied-arguement/#findComment-389243 Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 If the query is inside a function you might have to pass $conn1 var to it. Link to comment https://forums.phpfreaks.com/topic/76867-solved-query-not-a-supplied-arguement/#findComment-389245 Share on other sites More sharing options...
BlueSkyIS Posted November 11, 2007 Share Posted November 11, 2007 yes, the problem is $conn1. either don't set it or make sure it's set. have you echo'd it before the mysql_query() to see what it is? Link to comment https://forums.phpfreaks.com/topic/76867-solved-query-not-a-supplied-arguement/#findComment-389248 Share on other sites More sharing options...
L Posted November 11, 2007 Author Share Posted November 11, 2007 awesomeness, you guys rock. Thanks a lot! Because you singled down to the query I was able to retrace my steps, and I found out that the database.php which has my $conn1 was incorrectly "required"(require('') on the file. I got confused because since it is required shouldn't it have shown an error? But thanks again! Link to comment https://forums.phpfreaks.com/topic/76867-solved-query-not-a-supplied-arguement/#findComment-389328 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.