Jump to content

PHP SQL profile updates


scarezekiel

Recommended Posts

i dont know why it doesnt update the db..someone help??

 

$connection=mysql_connect("$server", "$username", "$password")

or die("Could not establish connection");

mysql_select_db($database_name, $connection)

or die ("Could not select database");

 

$strEditProfile = "UPDATE tblemployee SET EmployeeName='".$_POST["edit_thename"]."',

Address1 = '".$_POST[edit_address1]."',

Address2 = '".$_POST[edit_address2]."',

DesignationID = '".$_POST[edit_des]."',

Postcode = '".$_POST[edit_postcode]."',

State = '".$_POST[edit_state]."',

Country = '".$_POST[edit_country]."',

Tel1 = '".$_POST[edit_contact]."'

WHERE EEmail='".$_POST["edit_email"]."'";

 

$resEditProfile = mysql_query($strEditProfile);

if($resEditProfile)

echo "<img src=\"images/valid.jpg\" /> Profile updated!";

else

echo "><img src=\"images/warning.jpg\">Error!";

 

Link to comment
Share on other sites

Had a little time so worked on it. This is your query

 

$strEditProfile = "UPDATE tblemployee SET EmployeeName=".$_POST['edit_thename'].",
Address1 = ".$_POST['edit_address1'].",
Address2 = ".$_POST['edit_address2'].",
DesignationID = ".$_POST['edit_des'].",
Postcode = ".$_POST['edit_postcode'].",
State = ".$_POST['edit_state'].",
Country = ".$_POST['edit_country'].",
Tel1 = ".$_POST['edit_contact'].",
WHERE EEmail=".$_POST['edit_email'];

Link to comment
Share on other sites

Sunfighter, the code you have given will not work if the content of any of those variables have a space in them.

You should also use backticks for the field names (`)

 

This is the updated code:

<?PHP

  $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection");
  mysql_select_db($database_name, $connection) or die ("Could not select database");

  $strEditProfile = "UPDATE `tblemployee` SET `EmployeeName`='{$_POST['edit_thename']}',
                    `Address1` = '{$_POST['edit_address1']}',
                    `Address2` = '{$_POST['edit_address2']}',
                    `DesignationID` = '{$_POST['edit_des']}',
                    `Postcode` = '{$_POST['edit_postcode']}',
                    `State` = '{$_POST['edit_state']}',
                    `Country` = '{$_POST['edit_country']},
                    `Tel1` = '{$_POST['edit_contact']}',
                     WHERE `EEmail` = '{$_POST['edit_email']}';";

  if(mysql_affected_rows()) {
    echo '<img src="images/valid.jpg">Profile updated!';
  } else {
    echo '<img src="images/warning.jpg">Error!';
  }
  
?>

Link to comment
Share on other sites

thx for d help guys, i think i found d problem..but i forgot to include it in my codes d other day.

 

<form action="index.php?view=editprofile_do" method="post">

<input type="hidden" name="edit_email" value=<?php echo $user; ?> <br />

 

d other day i used ( value=<$user>  instead of    value=<?php echo $user; ?>  )

lol my mistake..im new to PHP.

Link to comment
Share on other sites

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.