Page 1 of 1

putting this into a variable

Posted: Fri Apr 11, 2014 2:52 pm
by nite4000
I have the here in a query and it works fine however I need to put this into a variable like $var = code but nothing I have tried workds

the code is this

Code: Select all

" . "NOW() + INTERVAL " . $row["dbfield"] . " DAY"."
I have tried

Code: Select all

$var = "NOW() + INTERVAL " . $row["dbfield"] . "DAY";
will no luck when ran it don't insert into the table

Re: putting this into a variable

Posted: Fri Apr 11, 2014 5:08 pm
by Christopher
What do you get if you do:

Code: Select all

$var = "NOW() + INTERVAL " . $row["dbfield"] . "DAY";
echo $var;
There are many reasons why the SQL might fail. But first you need to echo your SQL and see if it is valid. The variable $row["dbfield"] might be empty. It may be a SQL syntax error.

Also, what error message do you get when the query fails?