0

Hi All,

Can anybody see why this code wouldnt update the database?

Cheers

Paul

$me = $_SESSION['user_id'];
 $user_title = $_POST['user_title'];
$user_fname = $_POST['user_fname'];
$user_lname = $_POST['user_lname'];
$user_add1 = $_POST['user_add1'];
$user_add2 = $_POST['user_add2'];
$user_city_state = $_POST['user_city_state'];
$user_post_zip = $_POST['user_post_zip'];
$user_email = $_POST['user_email'];
$user_password = $_POST['user_password'];

// Connect to server and select databse.
$conn = mysql_connect("localhost", "un", "pw")or die("cannot connect");
mysql_select_db("db", $conn);
$sql = "UPDATE tbl_user SET user_title = '$user_title',user_fname = '$user_fname',user_lname = '$user_lname',user_add1 = '$user_add1',user_add2 = '$user_add2',user_city_state = '$user_city_state',user_post_zip = '$user_post_zip',user_email = '$user_email',user_password = '$user_password', WHERE user_id = $me";
$result = mysql_query($sql);
echo "thanks";
5
Contributors
4
Replies
8
Views
7 Years
Discussion Span
Last Post by shashankshah
0

I believe you have an extraneous comma before the WHERE in your query, but you don't have any error-checking.

To help correct this, add

if (!$result)
   {
   die("Unable to update table ".mysql_error($conn));
   }

after line 16.

See if that tells you anything. Then report back

Edited by Fbody: n/a

0

take the tick marks off of the variable names. they are being parsed as literal strings.

0

I too too think you have an extra , after where. Also i think after where has to have ' around $me like this:

WHERE user_id = '$me'"
0

"UPDATE tbl_user SET user_title = '".$user_title."',user_fname = '".$user_fname."',user_lname = '".$user_lname."',user_add1 = '".$user_add1."',user_add2 = '".$user_add2."',user_city_state = '".$user_city_state."',user_post_zip = '".$user_post_zip."',user_email = '".$user_email."',user_password = '".$user_password."' WHERE user_id = ".$me

Replace your query with the above query. It will work then. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.