MySQL Syntax Error in PHP Script -
i have query in mysql works fine, when copy query on php file, throwing me syntax error: ** unexpected ") week_ending ** missing?
mysql:
'select count(*)
count,region, date_format(now(),'%d %b %y')week_endingstores.statsdate> date_add(date(now()), interval -1 week) ,date< date(now()) groupregion, date(now())';
php:
$stmt = db::query(database::select, 'select count(*)
count,region, date_format(now(),'%d %b %y'),week_endingstores.statsdate> date_add(date(now()), interval -1 week) ,date< date(now()) groupregion, date(now())';
there couple single quotes in middle of sql prematurely terminating request. need escape quotes near here:
date_format(now(),'%d %b %y'), like this:
date_format(now(),\'%d %b %y\'),
Comments
Post a Comment