Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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