oavs Posted July 10, 2003 Share Posted July 10, 2003 Does anyone know why I am getting the message \'Query was empty\' I get this \'Query was empty\' after inserting code line //3 Also my record set dissappearing from the DW MX server behavior window after the code marked //3. <?php require_once(\'../Connections/connMDB.php\'); ?> <?php // 1 $txtKeywords_rsResults = "myKeywords"; if (isset($HTTP_POST_VARS[\'txtKeywords\'])) { $txtKeywords_rsResults = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS[\'txtKeywords\'] : addslashes($HTTP_POST_VARS[\'txtKeywords\']); } $txtArtist_rsResults = "myArtist"; if (isset($HTTP_POST_VARS[\'txtArtist\'])) { $txtArtist_rsResults = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS[\'txtArtist\'] : addslashes($HTTP_POST_VARS[\'txtArtist\']); } $txtTitle_rsResults = "myTitle"; if (isset($HTTP_POST_VARS[\'txtTitle\'])) { $txtTitle_rsResults = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS[\'txtTitle\'] : addslashes($HTTP_POST_VARS[\'txtTitle\']); } // 2 mysql_select_db($database_connMDB, $connMDB); $rsResults = mysql_query($query_rsResults, $connMDB) or die(mysql_error()); $row_rsResults = mysql_fetch_assoc($rsResults); $totalRows_rsResults = mysql_num_rows($rsResults); // 3 if ($HTTP_POST_VARS[\'radType\']==\'AND\') { $query_rsResults = sprintf("SELECT mdbTable.AlbumName, mdbTable.AlbumArtist, mdbTable.Keywords FROM mdbTable WHERE mdbTable.AlbumName LIKE \'%%%s%%\' AND mdbTable.AlbumArtist LIKE \'%%%s%%\' AND mdbTable.Keywords LIKE \'%%%s%%\'", $txtTitle_rsResults,$txtArtist_rsResults,$txtKeywords_rsResults); } else { // 4 $fieldArray = array(); // 5 if ($txtTitle_rsResults!=\'\') { $fieldArray[count($fieldArray)] = sprintf("mdbTable.AlbumName LIKE \'%%%s%%\'",$txtTitle_rsResults); } if ($txtArtist_rsResults!=\'\') { $fieldArray[count($fieldArray)] = sprintf("mdbTable.AlbumArtist LIKE \'%%%s%%\'",$txtAuthor_rsResults); } if ($txtKeywords_rsResults!=\'\') { $fieldArray[count($fieldArray)] = sprintf("mdbTable.Keywords LIKE \'%%%s%%\'",$txtKeywords_rsResults); } // 6 $query = implode(" OR ",$fieldArray); if ($query=="") { $query_rsResults = "SELECT * FROM mdbTable WHERE AlbumID=0"; } else { // 7 $query_rsResults = "SELECT mdbTable.AlbumName, mdbTable.AlbumArtist, mdbTable.Keywords FROM mdbTable WHERE ".$query; } } // 8 - end of Serach Code ?> Quote Link to comment https://forums.phpfreaks.com/topic/692-help-with-my-mysql-search-code/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.