Jump to content

mysql update question


justinh

Recommended Posts

 

$edit = mysql_query("UPDATE reservations SET firstname = '$firstname', description = '$description' WHERE id = '$id' && reservationdate = '$reservationdate'") or die(mysql_error());

 

cant seem to find out why this isnt updating the table..

thanks in advance

Link to comment
Share on other sites

well im pretty sure..

 

http://www.wmptest.com/HuntReserver/process.php?id=1182008

 

you can see the edit button url is getting the gets from the table

 

edit_reservation.php

<?PHP

INCLUDE("connect.php");

$id = $_GET['date'];
$reservationdate = $_GET['id'];

$query = mysql_query("SELECT * FROM reservations WHERE id = '$id' && reservationdate = '$reservationdate'") or die(mysql_error());
while($row = mysql_fetch_array($query)){

$firstname = $row['firstname'];
$description = $row['description'];

}
if (!isset($_POST['edit'])){

echo "<html><head><title>Hunt Reserver - Edit Reservation</title></head><body bgcolor=black><p align=center><img src=\"logo.jpeg\"><br>
<table><tr><td colspan=2><p align=center><font color=white size=2><b>Edit Reservation</b></td></tr><td><font color=white size=2>First Name:
</td><td><form action=\"".$_SERVER['php_self']."\" method=\"POST\"><input type=\"text\" value=$firstname name=firstname></td></tr><tr><td>
<font color=white size=2>Description</td><td><input type=\"text\" value=$description name=description></td></tr><tr><td colspan=2>
<p align=right><input type=\"submit\" value=\"Edit\" name=\"edit\"></form></table></body></html>";

}else{
$query = "UPDATE reservations SET firstname = '$firstname', description = '$description' WHERE id = '$id' && reservationdate = '$reservationdate'";
echo $query;
echo "<html><head><title>Hunt Reserver - Edit Reservation</title></head><body bgcolor=black><p align=center><img src=logo.jpeg><br><font size=2 color=white>Reservation Edited.</body></html>";

      }

      ?>

Link to comment
Share on other sites

Okay so let me get this straight: You're saying that in your table, the id column holds the date, and the reservationdate column holds the id? If so...(lol?)...

 

next guess is to again, check to make sure there is a row with 9 and 1182008 in it.  Perhaps, for instance, 1182008 should be 11082008 or some other format?

Link to comment
Share on other sites

 <?PHP

INCLUDE("connect.php");

$id = $_GET['date'];
$reservationdate = $_GET['id'];

$query = mysql_query("SELECT * FROM reservations WHERE id = '$id' && reservationdate = '$reservationdate'") or die(mysql_error());
while($row = mysql_fetch_array($query)){

$firstname = $row['firstname'];
$description = $row['description'];

}
if (!isset($_POST['edit'])){

echo "<html><head><title>Hunt Reserver - Edit Reservation</title></head><body bgcolor=black><p align=center><img src=\"logo.jpeg\"><br>
<table><tr><td colspan=2><p align=center><font color=white size=2><b>Edit Reservation</b></td></tr><td><font color=white size=2>First Name:
</td><td><form action=\"".$_SERVER['php_self']."\" method=\"POST\"><input type=\"text\" value=$firstname name=firstname></td></tr><tr><td>
<font color=white size=2>Description</td><td><input type=\"text\" value=$description name=description></td></tr><tr><td colspan=2>
<p align=right><input type=\"submit\" value=\"Edit\" name=\"edit\"></form></table></body></html>";

}else{
$query_update = mysql_query("UPDATE reservations SET firstname = '$firstname', description = '$description' WHERE id = '$id' AND reservationdate = '$reservationdate'") or die(mysql_error());


echo "<html><head><title>Hunt Reserver - Edit Reservation</title></head><body bgcolor=black><p align=center><img src=logo.jpeg><br><font size=2 color=white>Reservation Edited.<meta http-equiv=\"refresh\" content=\"2;url=http://www.wmptest.com/huntreserver/calender.php\" /></body></html>";

      }
?>

 

reports no errors.. just says Reservation Edited.

 

Link to comment
Share on other sites

id is set to primary so i took out reservationdate

 

 

still the same result.

 

the output is: Reservation Edited. ( redirects to calender.php )

 

 
<?PHP

INCLUDE("connect.php");

$id = $_GET['date'];
$reservationdate = $_GET['id'];

$query = mysql_query("SELECT * FROM reservations WHERE id = '$id' && reservationdate = '$reservationdate'") or die(mysql_error());
while($row = mysql_fetch_array($query)){

$firstname = $row['firstname'];
$description = $row['description'];

}
if (!isset($_POST['edit'])){

echo "<html><head><title>Hunt Reserver - Edit Reservation</title></head><body bgcolor=black><p align=center><img src=\"logo.jpeg\"><br>
<table><tr><td colspan=2><p align=center><font color=white size=2><b>Edit Reservation</b></td></tr><td><font color=white size=2>First Name:
</td><td><form action=\"".$_SERVER['php_self']."\" method=\"POST\"><input type=\"text\" value=$firstname name=firstname></td></tr><tr><td>
<font color=white size=2>Description</td><td><input type=\"text\" value=$description name=description></td></tr><tr><td colspan=2>
<p align=right><input type=\"submit\" value=\"Edit\" name=\"edit\"></form></table></body></html>";

}else{
$query_update = mysql_query("UPDATE reservations SET firstname = '$firstname', description = '$description' WHERE id = '$id'") or die(mysql_error());


echo "<html><head><title>Hunt Reserver - Edit Reservation</title></head><body bgcolor=black><p align=center><img src=logo.jpeg><br><font size=2 color=white>Reservation Edited.<meta http-equiv=\"refresh\" content=\"2;url=http://www.wmptest.com/huntreserver/calender.php\" /></body></html>";

      }
?>

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.