954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

UPDATE query not working properly...




User :

<?
$user = $_GET["user"];

$query = "SELECT * FROM userinfo WHERE user_name ='$user'";
$result = mysql_query($query);

$id = 0;

if(mysql_num_rows($result) > 0)
{
$row = mysql_fetch_object($result);
$id = $row->autoID;
?>


Username :


Password :


Email :


Percent Complete :


Temporary Price :


Amount Paid :


Date for completion :



<?
}

$txt_username = $_POST["txt_username"];
$txt_email = $_POST["txt_email"];
$txt_percentcomplete = $_POST["txt_percentcomplete"];
$txt_tempprice = $_POST["txt_tempprice"];
$txt_amountpaid = $_POST["txt_amountpaid"];
$txt_datecomplete = $_POST["txt_datecomplete"];

/*if( ($txt_username != $row->user_name) ||
($txt_email != $row->user_email) ||
($txt_percentcomplete != $row->percentcomplete) ||
($txt_tempprice != $row->tempprice) ||
($txt_amountpaid != $row->amountpaid) ||
($txt_datecomplete != $row->dateforcomplete) )
{*/
$query2 = "UPDATE userinfo SET user_name='$txt_username' WHERE autoID='$id'";
mysql_query($query2, $connection);
//}

?>

Woobag
Light Poster
33 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

Hi Woobag ,
you should use
'<?php echo $_SERVER['PHP_SELF']; ?>' instead of'<?php echo $PHP_SELF; ?>' There is no problem with your UPDATE statement since php echo it nicely,but you've used $PHP_SELF incorrectly.
I hope this help you.
Good luck.

mostafadotnet
Junior Poster
157 posts since Jul 2006
Reputation Points: 55
Solved Threads: 11
 

Thanks for the help mostafadotnet, but my problem appeared to be not the actual update query itself. Once i hit the first submit button the query was running with an "empty" value because it had not gotten the values from the POST. Therefore i simply adding an if statement correcting this flaw. Took me a week of on and off debugging to find that thing!

Woobag
Light Poster
33 posts since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You