Jump to content
xisto Community
sajja

View Members Profile

Recommended Posts

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 40

here 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 by rvalkass (see edit history)

Share this post


Link to post
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.