Jump to content

Recommended Posts

Hi,

 

I have this php search script, but when I run it I just get this

 

country:

type:

Abstract:

 

This is the right layout but it is not filling it with results.

The php code is

 

<?php 

// Connects to your Database 
mysql_connect("localhost", "adder", "clifford") or die(mysql_error()) ; 
mysql_select_db("real") or die(mysql_error()) ;

$country = isset($_POST['menuFilesDMA']) ? preg_replace('/[^a-zA-Z0-9\ ]/', '', $_POST['menuFilesDMA']) : ''; 
$type = isset($_POST['Type']) ? preg_replace('/[^a-zA-Z0-9\ ]/', '', $_POST['Type']) : ''; 
$Abstract = isset($_POST['keyword']) ? preg_replace('/[^a-zA-Z0-9\ ]/', '', $_POST['keyword']) : ''; 

if ($country) { 
     $where[] = "country='$country'"; 
} 
if ($type) { 
     $where[] = "type='$type'"; 
} 
if ($Abstract ) { 
     $where[] = "Abstract LIKE '%$Abstract%'"; 
} 
if ($where) { 
     $sql = "SELECT * FROM items WHERE " . implode(' AND ', $where); 
     // query and display results 
} 


{ 

//Outputs the image and other data
Echo "<b>country:</b> ".$info['country'] . "<br> "; 
Echo "<b>type:</b> ".$info['type'] . " <br>"; 
Echo "<b>Abstract:</b> ".$info['Abstract'] . " <hr>"; 
} 
?>

 

Any help would be much appriciated,

 

Thanks,

Colin

Link to comment
https://forums.phpfreaks.com/topic/68349-missing-search-results/
Share on other sites

Hi Colin,

 

Could you provide the following pieces of information so I can see what's going on a bit better.

 

1. The piece of code that populates $info. It's probably pretty simple but may contain a typo. That's one of my major gripes about PHP so I'm always double checking spelling. I come from a C/C++ background where any typos at least have to be consistent.

 

2. Echo the $sql string to make sure it looks okay and that the fields you're querying actually match data in the database.

 

3. Are you getting any errors from mysql_query? The mysql_error() function is very useful for debugging, though you may want to remove it before going live.

 

Cheers,

Darren.

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.