Jump to content

Trouble with session string for mysql


paulc8481

Recommended Posts

Can someone please explain to me why I cant seem to get my mysql update line to work.  I have been trying for a while an still nothing.  I am new in php and need some help getting this to work.  Please be gentle.  a good explaination in newbie talk would be appreciated.

 

The session variable I echoed out does work so I know I am reading the variable in from the other page.

 

thanks

 

<?php

session_start();

 

/*

Server side scripting with php

CISS 225

Lab # Final Project

*/

//This section will create variables collected from information sent

//by the post method on the createUserProcess.

 

/*      $_SESSION['city'] = $_POST['city'];

$_SESSION['state'] = $_POST['state'];

$_SESSION['zipCode'] = $_POST['zipCode'];

$_SESSION['profession'] = $_POST['profession'];

$_SESSION['activities'] = $_POST['activities'];

$_SESSION['hobbies'] = $_POST['hobbies'];

*/

$city = $_POST['city'];

$state = $_POST['state'];

$zipCode = $_POST['zipCode'];

$profession = $_POST['profession'];

$activities = $_POST['activities'];

$hobbies = $_POST['hobbies'];

 

$db = mysql_connect("localhost", "root", "");

mysql_select_db("accountprofile",$db);

 

echo $_SESSION['Email'];

//$query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession', " . "

//activities = '$activities', hobbies = '$hobbies' WHERE lastName = 'Hildebrand'";

$query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession',

activities = '$activities', hobbies = '$hobbies' WHERE userName = " .$_SESSION['Email']."";                 mysql_query($query,$db);

if (mysql_error())

{

    echo "$query<br />";

    echo mysql_error();

}

 

echo "THANK YOU!<br />";

echo "Your profile has been completed!<br />";

?>

Link to comment
Share on other sites

$query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession',
   activities = '$activities', hobbies = '$hobbies' WHERE userName = '" .$_SESSION['Email']."'";

 

or more simply (less error prone, less typing) -

 

$query = "UPDATE accountprofile SET city = '$city', state = '$state', zipcode = '$zipCode', profession = '$profession',
   activities = '$activities', hobbies = '$hobbies' WHERE userName = '{$_SESSION['Email']}'";

 

Are you sure your userName column contains email addresses?

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.