PHP/MySQL Not updating DB from form anymore

时间:2016-04-15 11:14:35

标签: php mysql

I have been working on a program for a job interview coming up soon, and I was nearing the completion of the program which had everything running the way I needed it to... but then my computer crashed. When I opened up the files again, everything was the same, nothing changed, all my changes were saved before it crashed. Only thing is, now my MySQL table doesn't get the data sent to it from the INSERT code. Is there something I can do to make this work?

I have tried creating a new database, a different table, restarting my computers, restarting Chrome, everything.... I can't get it and I'm desperate at this point.

Please see the code below...

// Connect to the database.
$link2 = mysqli_connect("localhost", "cl60-booking", "XXXXXXX", "cl60-booking");

if (mysqli_connect_error()) {

    die ("There was an error connecting to the database");

} 

// Update the bookings DB with the user's hotel room.

$query = "INSERT INTO booking
          (`beds`, `baths`, `booked`, `checkInDate`, `checkOutDate`) 
          VALUES('".mysqli_real_escape_string($link2, 
                 $_POST['bedNumber'])."', 
                 '".mysqli_real_escape_string($link2, $_POST['bathNumber'])."', 
                 'Yes', '".mysqli_real_escape_string($link2, 
                 $_POST['checkIn'])."',
                 '".mysqli_real_escape_string($link2, 
                 $_POST['checkOut'])."')";

1 个答案:

答案 0 :(得分:0)

使用以下代码段:

mysqli_query($link2, $query);