skip to Main Content
$sql = "INSERT INTO `liftcentrale`(`timedate`,`vraagaanbod`, `date`, `from_place`, `to_place`, `name`, `email`, `gender`, `smoke`, `extra`, `freeyesno`, `price_euro`, `firsttimeryesno`, `seats_offered`)
VALUES (CURRENT_TIMESTAMP,'$vraagaanbod','$date','$from_place','$to_place','$name','$email','$gender','$smoke','$extra','$freeyesno','$price_euro','$firsttimeryesno','$seats_offered');";

echo $sql; //CHECK QUERY STRING

if ($conn->query($sql) === TRUE) {
  echo "New record created successfully";
} else {
  echo "Error: " . $sql . "<br>" . $conn->error;
}

I tried using phpMyAdmin to create php statements. Changed the single parentheses that phpMyAdmin created for ‘normal’ ones. Tried and tested over & again. Can’t find a working solution otherwise would not be here. For some reason, I can not even see the query string.

2

Answers


  1. Chosen as BEST ANSWER

    Checking my error logs definitely helped, after I installed MAMP on my own laptop to see what these logs said. DB name was wrong, and the date format. I now can insert data into MySQL. Thanks for all the help!


  2. Try like this

    $sql = "INSERT INTO `table_name` (`a`, `b`, `c`) VALUES (CURRENT_TIMESTAMP, '". $value1 ."', '". $value2 ."');";
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search