Querying from PHP to a MySQL database

From: Date: Fri, 20 Sep 2002 15:15:39 +0000
Subject: Querying from PHP to a MySQL database
Groups: php.general 
Request: Send a blank email to php-general+get-117026@lists.php.net to get a copy of this message
Howdy all! I've built a page in Dreamweaver MX that uses PHP for scripting. I can get data out of my mysql database but I need to be able to search for wildcards. currently it only matches 100% exact queries. Below is the code that is at the beggining of the PHP page. ----------- $varSort_search1 = "%"; if (isset($HTTP_POST_VARS["Sort"])) { $varSort_search1 = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS["Sort"] : addslashes($HTTP_POST_VARS["Sort"]); } $varText_search1 = "%"; if (isset($HTTP_POST_VARS["Text"])) { $varText_search1 = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS["Text"] : addslashes($HTTP_POST_VARS["Text"]); } mysql_select_db($database_CATCH, $CATCH); $query_search1 = sprintf("SELECT * FROM secureworks WHERE %s LIKE '%s'", $varSort_search1,$varText_search1); $search1 = mysql_query($query_search1, $CATCH) or die(mysql_error()); $row_search1 = mysql_fetch_assoc($search1); $totalRows_search1 = mysql_num_rows($search1); ------------- Does anyone have any ideas? Thanks, John Cole, TCISA

« previous php.general (#117026) next »