Page 1 of 1

[SOLVED]: How to combine a php variable in a sql query

Posted: Wed Jan 06, 2010 12:32 am
by ecxzqute
Hey guys!,

Im currently coding php and have to produce a report. now i have this query that needs to have a condition that is stored in a variable...

here's a part of my code/query:

Code: Select all

 
    , (SUM(SHH.REG) * (SHH.DailyRate/".$regwhours.")) TotalDailyRate
    , SUM(SSH.DailyRateReg) GrandDailyRate
 
The first line produces an error..
Any ideas is very much appreciated!

Re: How to combine a php variable in a sql query using mysql

Posted: Thu Jan 07, 2010 3:21 am
by aravona
ecxzqute wrote:
The first line produces an error..
Would be more useful if you posted the error for us :)

Re: How to combine a php variable in a sql query using mysql

Posted: Mon Jan 18, 2010 5:20 am
by ecxzqute
im sorry for the late reply, i've been busy for the past few days..
well i've been able to solve the problem..
i figured out that i have to put single quotes ('') before and after the variable
$regwhours..

so, from , (SUM(SHH.REG) * (SHH.DailyRate/".$regwhours.")) TotalDailyRate

comes , (SUM(SHH.REG) * (SHH.DailyRate/'".$regwhours."')) TotalDailyRate