Jump to content

Help with edit profile


hoponhiggo

Recommended Posts

Hi

 

I am trying to develop an editprofile.php page to allow users to change their details.

 

So far i have written

 

<?php

$result = mysql_query("SELECT username FROM users WHERE username = {$_SESSION['MM_Username']}");

$num_rows = mysql_num_rows($result);
  
if($num_rows > 0)
{
	while ($row = mysql_fetch_array($result))
	{
		$username = $row['username'];
	}


}
?>

 

and then tried to test it by using

 

<div><?php echo $username ?></div>

 

but nothing is being echo'ed out. What am i doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/243176-help-with-edit-profile/
Share on other sites

You could test with simple echop inside your IF, if the mysql query actually returned something. Set or die(mysql_error()) after your query to see if it gives any errors. Also before echoing the $username variable you could do var_dump($username); to see if that variable has anything inside it.

  • 4 weeks later...

While yes you could simply have echoed the session variable, you will later still need to retrieve the rest of the details for the user to see and edit. So you need to add the error / empty result set checks, and alter your query to return more of the columns.

Archived

This topic is now archived and is closed to further replies.

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