I tried both
$query = "INSERT INTO reservation VALUES ('".$hour."','".$minute."','".$day."','".$month."','".$year."','".$name."','".$table."')";
$query = "INSERT INTO reservation VALUES ('$hour','$minute','$day','$month','$year','$name','$table')";
But none of them work, I get a blank page, and no errors in my error logs. I tried doing echo to all the variables and I got their values.
Here is the overall function:
function makeReservation($trtime,$hour,$minute,$day,$month,$year,$name,$table,&$db)
{
//$query = "INSERT INTO reservation VALUES ('".$hour."','".$minute."','".$day."','".$month."','".$year."','".$name."','".$table."')";
$query = "INSERT INTO reservation VALUES ('$hour','$minute','$day','$month','$year','$name','$table')";
$result = $db->query($query) or die(mysql_error());
}
I’ll make a few suggestions. First, I’ll assume that you actually know what you’re doing when you say there is no error.
1) Make sure you work on the good database. You can do a
SHOW TABLESquery to see what tables it contains, or aSELECT * FROM reservationto see its content.2) Right after you insert the row, do a
SELECT * FROM reservationquery and check if your row is there.3) Make sure you call your function…
Then, as I said in comments, you should use the DATETIME type instead of using different columns for hours, minutes, etc. If you need to select a particular attribute, use the appropriate function (for example,
SELECT HOUR(your_column))The quotes around integers shouldn’t make your query fails, but it’s still better for clean code purposes to remove them if not necessary (and make sure you escape your data correctly, of course).