chrischen Posted February 9, 2008 Share Posted February 9, 2008 Right now if I type "%" into my search box it returns everything in the databse. How do I escape it so that it searches for that sign? Link to comment https://forums.phpfreaks.com/topic/90150-searching-for-sign/ Share on other sites More sharing options...
toplay Posted February 9, 2008 Share Posted February 9, 2008 \% Link to comment https://forums.phpfreaks.com/topic/90150-searching-for-sign/#findComment-462294 Share on other sites More sharing options...
Barand Posted February 9, 2008 Share Posted February 9, 2008 so to search for a value containing a % ...WHERE term LIKE '%\%%' Link to comment https://forums.phpfreaks.com/topic/90150-searching-for-sign/#findComment-462300 Share on other sites More sharing options...
chrischen Posted February 9, 2008 Author Share Posted February 9, 2008 I tried and it still returns everything. $query = "%"; The sql query is like this sprintf("... WHERE name = %s", GetSQLValueString($query, "text") and I use the GetSQLValueString function: function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } Link to comment https://forums.phpfreaks.com/topic/90150-searching-for-sign/#findComment-462312 Share on other sites More sharing options...
fenway Posted February 9, 2008 Share Posted February 9, 2008 I see no escaping. Link to comment https://forums.phpfreaks.com/topic/90150-searching-for-sign/#findComment-462803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.