0

I'd like to use a variable number of seconds ($seconds_to_add) in the DATE_ADD() function but it dosen't work. Is it possible ?

<?php
$requete = $pdo->prepare('UPDATE pages SET
    vote_time_limit =  DATE_ADD(vote_time_limit, INTERVAL :seconds_to_add SECOND)
    WHERE page_ID=:id_page');

$requete->bindValue(':id_page', $id_page);
$requete->bindValue(':seconds_to_add', $seconds_to_add);
1
  • 1
    how it doesn't work ? you have some debug messages? Commented Aug 29, 2011 at 16:31

1 Answer 1

1

Bind it as an int, because the default is a string (which includes quotes).

$requete->bindValue(':seconds_to_add', $seconds_to_add, PDO::PARAM_INT);

I recommend you do it on the ID too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.