Jump to content

mysql update question


justinh

Recommended Posts

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>";

      }

      ?>

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?

 <?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.

 

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>";

      }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.