Jump to content

[SOLVED] query not a supplied arguement!


L

Recommended Posts

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

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?

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.