Jump to content

Archived

This topic is now archived and is closed to further replies.

oavs

help with my Mysql search code

Recommended Posts

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



?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.