echo $date1u
Gives me 2010-04-21
When I take that date and hardcode it into an SQL query it works fine
SELECT * FROM phoneappdetail WHERE salebarn = 'OSI' AND saledate = '2010-04-21'
But when I instead use the $date1u directly it doesn’t work at all.
"SELECT * FROM phoneappdetail WHERE salebarn = 'OSI' AND saledate = '".$date1u."' "
What is the problem with my variable $date1u or SQL format that is stopping this from working?
EDIT
Followed a suggestion and tried
$result1 = "SELECT * FROM phoneappdetail WHERE salebarn = 'OSI' AND saledate = '".$date1u."' ";
echo $result1;
To see the result and some how in this situation the out put is
SELECT * FROM phoneappdetail WHERE salebarn = 'OSI' AND saledate = '2010-04-22'
Some how when I echo $date1u alone its 2010-04-21 but when I echo the var in the SQL query 1 day got added
Do you have any whitespace either side of the variable – i.e. spaces or tabs? If so, this is probably whats causing the problem.
Try
echo ">>" . $date1u . "<<";If you get “>> 2010-04-21<<” you’ll know you have a leading space. Getting the variable length may also help pinpoint problems.