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
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?

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.