MySQL parameter resource error

Posted by Derek on Stack Overflow See other posts from Stack Overflow or by Derek
Published on 2010-04-07T14:05:48Z Indexed on 2010/04/07 14:13 UTC
Read the original article Hit count: 238

Filed under:
|
|
|

Here is my error:

Warning: mysql_query() expects parameter 2 to be resource, null given...

This refers to line 23 of my code which is:

$result = mysql_query($sql, $connection)

My entire query code looks like this:

$query = "SELECT * from users WHERE userid='".intval( $_SESSION['SESS_USERID'] )."'"; 
                $result = mysql_query($query, $connection)
                or die ("Couldn't perform query $query <br />".mysql_error());

                $row = mysql_fetch_array($result);

I don't have a clue what has happpened here. All I wanted to do was to have the value of the users 'fullname' displayed in the header section of my web page. So I am outputting this code immediately after to try and achieve this:

echo 'Hello '; echo $row['fullname'];

Before this change, I had it working perfectly, where the session variable of fullname was echoed $_SESSION['SESS_NAME']. However, because my user can update their information (including their name), I wanted the name displayed in the header to be updated accordingly, and not displaying the session value.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql