sajja 0 Report post Posted October 8, 2010 (edited) hi.. i am receiving the following error to view my members profile. username not received.Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\devi\viewprofile.php on line 40here is the code:<?phpinclude 'functions.php';if(!loggedin()){header("Location: mlogin.php");exit();}?><?php include ("header.html"); include ("memmenu.html"); include ("profileinf.html"); $username = $_GET['username'];$con = mysql_connect("localhost","root","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("cricket", $con);if(isset($username)){$user =mysql_query( "SELECT * FROM `members` WHERE username='$username'");}else{echo"username not received.";}echo "<table align='' border='1'><tr><th>Fullname</th><th>Username</th><th>Date of Birth</th><th>Address</th><th>E-mail</th><th>Phonenumber</th></tr>";while($row = mysql_fetch_array($user)) { echo "<tr>"; echo "<td>" . $row['fullname'] . "</td>"; echo "<td>" . $row['username'] . "</td>"; echo "<td>" . $row['dob'] . "</td>"; echo "<td>" . $row['address'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['phonenumber'] . "</td>"; echo "</tr>"; }echo "</table>";echo "<br>"; echo '<form name="backlistfrm" method="post" action="profile.php">';echo '<input type="submit" value="Back to The List">';echo '</form>';echo "<br>";mysql_close($con); include ("footer.html");?> would u help me out.............? Edited October 8, 2010 by rvalkass (see edit history) Share this post Link to post Share on other sites
truefusion 3 Report post Posted October 8, 2010 According to the code logic, isset($username) returned false, therefore $user does not contain the resource that would have otherwise been given by mysql_query(). Since there is nothing in the code to fill $user with a resource when the "username not received," mysql_fetch_array() notices that no resource was provided, and so the error you receive. Share this post Link to post Share on other sites
sajja 0 Report post Posted October 10, 2010 how to receive the username back to this present working page from the login page......? Share this post Link to post Share on other sites
truefusion 3 Report post Posted October 11, 2010 how to receive the username back to this present working page from the login page......?I do not know your current code, but from what i can derive from the current scenario, your login page is letting people get through without the user providing a username. If this is not the case, then i cannot provide you with a solution. Either way, i wouldn't have relied on the $_GET variable to store a username (i would have considered $_COOKIE). Share this post Link to post Share on other sites