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: <?php echo $myrow["first_name"]?> <?php echo $myrow["last_name"]?><br>
Email:
<?php echo $email ?><br>
Minutes: <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>
 Seconds: <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
set update help
Moderator: General Moderators
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
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."'";
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."'";
maybe i am confused
but your wanting to update the emal, seconds and minutes field correct?
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.
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";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
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
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC