Kimochi Posted August 23, 2008 Share Posted August 23, 2008 Please look at the following code. function product_differs($model, $quantity, $price) { echo $price.'<br />'; $q = 'SELECT * FROM `products` WHERE `products_model`="'.addslashes($model).'" AND `products_quantity`='.$quantity.' AND `products_price`='.$price; $differs_query = mysql_query($q) or die(mysql_error().' - '.$q); if(mysql_num_rows($differs_query) == 0) { $old_query = mysql_query('SELECT * FROM `products`,`products_description` WHERE `products`.products_model="'.addslashes($model).'" AND `products`.products_id=`products_description`.products_id') or die(mysql_error().'3'); return mysql_fetch_array($old_query); } else return false; } When I run this code with a variable I know to contain ">5", it gets echoed as 1 on the "echo $price.'<br />';" line, then the mysql_query uses the value ">5" which causes an SQL error (I cannot remove the ">", as when I use functions to do so the variable gets read as "1"), and then when I echo $q with the die() function I get a value of 1 again. This happens with the $price variable outside this function. It is retrieved from a text file. Any idea what's going on? Link to comment https://forums.phpfreaks.com/topic/120996-variables-not-retrieved-properly/ Share on other sites More sharing options...
kenrbnsn Posted August 23, 2008 Share Posted August 23, 2008 Your explanation is a little hard to follow. Which variable contains ">5"? Show use the query that causes the error. Ken Link to comment https://forums.phpfreaks.com/topic/120996-variables-not-retrieved-properly/#findComment-623732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.