putting this into a variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nite4000
Forum Contributor
Posts: 209
Joined: Sun Apr 12, 2009 11:31 am

putting this into a variable

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: putting this into a variable

Post 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?
(#10850)
Post Reply