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! Quote Link to comment 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? Quote Link to comment 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) Quote Link to comment 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! Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
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.