Page 1 of 1

set update help

Posted: Sat Mar 06, 2004 4:29 pm
by speedamp
hello everybody,

i have an update script that will not pass the proper variable for me. What i want to do is have a cusotmer update thei minutes/seconds depending on their variable $email (passed from the login screen).

Right now the output i get is not including the $email variable. Am I using the Update Set Where syntax properly?

-----------------------------------------------------------------------

<?php


$db = mysql_connect("localhost", "....", ".....");
mysql_select_db("......_com_prix",$db);
if($submit){


$sql = "UPDATE entrants SET minutes=$minutes,seconds=$seconds WHERE email=$email";
$result = mysql_query($sql);
header ("Location: http://www......com/change/edit_verify.php?email=".$email. "");

} else{

$query="SELECT * FROM entrants where email='$email' ";
$result=mysql_query($query);
$myrow=mysql_fetch_array($result);
?>

<form method="post" action="<?php echo $PHP_SELF?>">
First:&nbsp;&nbsp;<?php echo $myrow["first_name"]?>&nbsp;<?php echo $myrow["last_name"]?><br>
Email:&nbsp;&nbsp;
<?php echo $email ?><br>

Minutes:&nbsp;&nbsp;<select name="minutes"><br>
<OPTION VALUE="<?php echo $myrow["minutes"]?>"><?php echo $myrow["minutes"]?>
<OPTION VALUE="00">00
<OPTION VALUE="01">01
<OPTION VALUE="02">02
<OPTION VALUE="59">59
</SELECT>

&nbsp;&nbsp;&nbspSeconds:&nbsp;&nbsp;<select name="seconds"><br>
<OPTION VALUE="<?php echo $myrow["seconds"]?>"><?php echo $myrow["seconds"]?>
<OPTION VALUE="00">00
<OPTION VALUE="01">01
<OPTION VALUE="05">05
<OPTION VALUE="58">58
<OPTION VALUE="59">59</SELECT><br>

<input type="Submit" name="submit" value="Update Information">
</form>
<?php
}
?>
-------------------------------------------------

any help would be great?

-Michael

Posted: Sun Mar 07, 2004 4:36 am
by microthick
You need to wrap the email address with single quotes.

This is what you have:
$sql = "UPDATE entrants SET minutes=$minutes,seconds=$seconds WHERE email=$email";

Change it to:
$sql = "UPDATE entrants SET minutes=$minutes,seconds=$seconds WHERE email='$email'";

Or, even better:
$sql = "UPDATE entrants SET minutes = ".$minutes.", seconds = ".$seconds." WHERE email = '".$email."'";

Posted: Sun Mar 07, 2004 9:21 am
by speedamp
none of these methods actually pass the $email variable. The minutes and seconds are passed fine (using echo $sql), but the email variable is empty.

any suggestions?

Posted: Sun Mar 07, 2004 10:00 am
by tim
maybe i am confused

but your wanting to update the emal, seconds and minutes field correct?

Code: Select all

$sql = "UPDATE entrants SET minutes=$minutes,seconds=$seconds WHERE email=$email";
Look at that, of course its not going to pass the email field, the only thing email wise in that line is only telling where to set the minutes n seconds.

Posted: Sun Mar 07, 2004 10:24 am
by speedamp
sorry for the confusion, but the scope of this is that i want the user to be able to update their time (minutes/seconds) depending on their login email. I do not want their email changed or sent to the database.

When i display the $sql command i get this:
UPDATE entrants SET minutes=12,seconds=06 WHERE email=


so, the concept is working, but HOW do i get the email field to populate properly so it updates the database. i would rather not use sessions, but if it's my only choice, could somebody help me with them?

the email field is being passed to this page properly through the header, however once it enters the SQL command (and further into the header) it is lost.


I have tried formatting with '$email', $email, ".$email."

help!

-mike

Posted: Sun Mar 07, 2004 1:30 pm
by microthick
Oh, I see what the other guys were saying.

You aren't passing $email from the form page. You are just showing it on the screen. At the very least, you have to create a hidden form field called "email" that contains the $email address.