Hi Guys,

I am having trouble with my links, i am currently trying to use my $_SESSION; to automatically link it directly to the specific user page. However I always have this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\ThesisDB\DisplayThisUser.php on line 21

<?php
	session_start();
     function do_menu() {
	 
		 print "
      
        	<h5>[Status: User | <a href=\"logout.php\">
               <font size=-5>Logout</font></a> ]</h5>	 
		<a href=\"member-index.php\">Home</a> | 
                 <a href=\"logout.php\">Logout</a> |
		<a href=\"DisplayThisUser.php?ID_NO=";$_SESSION['SESS_MEMBER_ID']; 

		print "	
			\">Display My Info</a> | 
                          <a href=\"Plate_1.php\">Ishihara Test</a> |
			<a href=\"Upd2.php?ID_NO=1\">Edit My Info</a> 
            <HR>
        ";
    }

?>

i also have passed it using $ID_NO = $_SESSION;
but also same result. Is there any solution to this one?

Recommended Answers

All 7 Replies

still didnt get it

Hmm.. Are you using the statement mysql_num_rows($result) anywhere in your code.

As far as I have seen this error comes up when the sql statement being used for which you are getting the number of rows through the mysql_num_rows is incorrect. Is the error coming up for this code alone, or is this function a supplementary functio to your main code?

its an error coming up for this code alone.. i thought it should be working. It has been working in the others but not this one

Below is the code whenever the User logs in.

//Check whether the query was successful or not
	if($result) {
		if(mysql_num_rows($result) == 1) {
			//Login Successful
			session_regenerate_id();
			$user_info = mysql_fetch_assoc($result);
			$_SESSION['SESS_MEMBER_ID']  = $user_info['ID_NO'];
			$_SESSION['SESS_FIRST_NAME'] = $user_info['FNAME'];
			$_SESSION['SESS_LAST_NAME']  = $user_info['LNAME'];
			$_SESSION['SESS_admin']      = $user_info['admin'];
			//print "Login a success!";
			session_write_close();
			header("location: member-index.php");
			exit();
		}
                else {
			//Login failed
			header("location: login-failed.php");
			exit();
		}
	}

what is $result contains?

Ok I got it to work now >_<.

it was suppose to be

print "
<a href=\"DisplayThisUser.php?ID_NO= ". $_SESSION['SESS_MEMBER_ID']."\">Display My Info</a>

";

not this one

print "
<a href=\"DisplayThisUser.php?ID_NO=";
 $_SESSION['SESS_MEMBER_ID'];
 print "
\">Display My Info</a>
";

This is my thesis so I would/should solve it myself but thanks sudeepjd and Shanti Chepuru! :D

It is possible that the code works for other programs. It has to do with the DB structure.

Your $result would be getting a mysql_query($sql); somewhere before the statement. Echo the $sql onto the page and run it in your phpMyAdmin. see if it giving you an error or getting you the results you need. It will most probably give you an error. Once you correct that error, the program should work fine.

Let me know.

Hmm. Looks like we posted at the same time. Good to hear you got it working. Your welcome, and all the best on your thesis.

Please mark the thread as solved. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.