Saturday, July 30, 2011

Re: [phpXperts] mySQL Query with PHP variable is not working

 

As Sohel vai said, just make sure your date format is YYYY-MM-DD (eg. 2011-07-31) for both dates. and you wil be fine.

you can do this using strtotime and date -

$to_date = date('Y-m-d',strtotime($to_date));


On Sun, Jul 31, 2011 at 1:03 AM, rafiq sohel <rafiq7s@yahoo.com> wrote:
 

Be sure that $from_date and $to_date are having date values in 'YYYY-MM-DD' format (if the column type is date)

Use '".$from_date."' instead of '$from_date'
$query=mysql_query("select SUM(payment) as totalPayment from msa_payment WHERE date BETWEEN '".$from_date."' AND '".$to_date."'");


Regards,

Md. Rafiqul Islam (Shohel)
GMG Airlines Ltd.
Cell: +880 1911745532



From: azhar <eng.azharul@gmail.com>
To: phpexperts@yahoogroups.com
Sent: Saturday, 30 July 2011 4:41 PM
Subject: [phpXperts] mySQL Query with PHP variable is not working

 
my query is not working. The Query is

$query=mysql_query("select SUM(payment) as totalPayment from msa_payment WHERE date BETWEEN '$from_date' AND '$to_date'");

Please help me.






--
Anjan Bhowmik
Freelance Software & Web Developer
M : +880 - 1670 - 556419
E : anjan011@gmail.cominfo@ultrasoftbd.com
Site: http://www.onlyfreelancer.com/ - Only for Freelancer's!

__._,_.___
Recent Activity:
Visit phpXperts website at www.phpxperts.net
.

__,_._,___

No comments: