Note that there are some explanatory texts on larger screens.

plurals
  1. POseat reservation not working
    primarykey
    data
    text
    <p>I've been doing a lot of research but I guess I still didn't find the answers. This is a seat reservation and I'm not so good in php and mysql. So here's my code: </p> <p>reservation.php code:</p> <pre><code>&lt;?php mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db('seat_reservation') or die (mysql_error()); $insert = mysql_query("INSERT INTO reservation (chair_status, room_id, chair_number) VALUES (0, 400, 05)"); ?&gt; &lt;/td&gt; &lt;div id="popupContact"&gt; &lt;a id="popupContactClose"&gt;x&lt;/a&gt; &lt;center&gt;&lt;form method = "POST" action="reserve.php"&gt; &lt;?php $query = mysql_query("SELECT chair_status FROM reservation WHERE room_id = '400' AND chair_number = '05'"); while($row = mysql_fetch_array($query)) { $_SESSION['roomno'] = $row['room_id']; $_SESSION['chairnum'] = $row['chair_number']; } ?&gt; </code></pre> <p>reserve.php code:</p> <pre><code>&lt;?php $name = $_POST['student_name']; $stud_id = $_POST['stud_id']; $room_id = $_SESSION['roomno']; $chair_num = $_SESSION['chairnum']; mysql_connect("localhost", "root", "") or die (mysql_error()); mysql_select_db('seat_reservation') or die (mysql_error()); $query = mysql_query("SELECT chair_status FROM reservation WHERE room_id = '$room_id' AND chair_number = '$chair_num'"); if($query == 0) { $insert = mysql_query("UPDATE reservation SET chair_status = 1, student_name = '$name', stud_id = '$stud_id' WHERE room_id = '$room_id' AND chair_number = '$chair_num'"); } else die ("Sorry, seat taken! &lt;br /&gt;Redirecting...&lt;meta http-equiv='refresh' content=2;reservation.php&gt;"); ?&gt; </code></pre> <p>my problem is that, when I reserve a seat, it tells me that the seat is taken even if the chair_status field is 0. When I checked the DB, it successfully inserted with chair_status of 0. I don't know which part is wrong. I really need your help, thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload