Displaying variables in text - clarification needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all.

I inherited some PHP pages about a year ago. They have been fine all along but now a bunch of erroneous errors and results are popping up. I traced it to the way the variables were being used on the page... for example, the following SQL statement (a space between ' and " for clarity):


sql="select name from mytable where name=$myvar and display='yes' ";

This has worked in the past but is now returning errors for some records and working for others. I changed the above to the following and now all is good:

sql="select name from mytable where name=' ".$myvar." ' and display='yes' ";

What would explain why the former is suddenly causing problems? The version of PHP is 5.2.3 and from what I can tell, hasn't been updated since February of 2011.

Thanks,

 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux