Jump to content

help with my Mysql search code


oavs

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



?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.