0

So I have a table with the colums title,description,created, fk_u. Then I have this statement:

$stmt = $conn->prepare( "insert into blogs1(title,description,created,fk_u) values(?,?,?,?)");

Afterwards I try to bind the parameters with bind_param().

$stmt->bind_param("ssii", $title,$desc,NOW(),$id);

The Problem I get is that it dosen't recognise the NOW() function. What could be the error. Am I using the bind_param function wrong?

samuel gast
  • 331
  • 4
  • 17
  • 3
    `NOW()` is not a PHP function, it's a MySQL function. It does not need to be bound since it's not user data. Just add it directly into your query. – aynber Dec 18 '18 at 18:26
  • True. I should have come up with that solution myself. But thanks ! – samuel gast Dec 18 '18 at 18:30

1 Answers1

3

NOW() is MySQL, so move this to your SQL and remove the bind...

$stmt = $conn->prepare( "insert into blogs1(title,description,created,fk_u) 
                  values(?,?,NOW(),?)");

$stmt->bind_param("ssi", $title,$desc,$id);
Nigel Ren
  • 56,122
  • 11
  • 43
  • 55