Displaying variables in text - clarification needed

From: Date: Wed, 26 Oct 2011 12:20:33 +0000
Subject: Displaying variables in text - clarification needed
Groups: php.general 
Request: Send a blank email to php-general+get-315438@lists.php.net to get a copy of this message
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

« previous php.general (#315438) next »