Jump to content


MySQL Database Search


2 replies to this topic

#1 Scion

    Young Padawan

  • Members
  • Pip
  • 25 posts
  • Gender:Male
  • Interests:Basketball, baseball, volleyball, web design, graphic design, reading, watching movies.

Posted 14 November 2007 - 06:13 PM

Hi,

I am creating a MySQL Database Search, but I had a quick question. If I enter a search term that is not inside the MySQL Database, (such as random gibberish), will it come up with blank information, or will it give me an error?

Thanks,
Scion

Edited by Scion, 14 November 2007 - 07:53 PM.


#2 Archangel

    P2L Jedi

  • Members
  • PipPipPip
  • 988 posts
  • Gender:Male
  • Location:Indiana
  • Interests:Reading (mainly fantasy books), Gaming (Xbox 360, Wii & PS3), Sports, Outdoor Recreation, Watching/Collecting Movies

Posted 14 November 2007 - 11:05 PM

I'm sure there might be a better way to do it, but here's how I have done it before...

$data = mysql_query("blah blah");
$drows= mysql_num_rows($data);

if($drows >= 1){
//do stuff
}else{
//nothing was found
}

Edited by Archangel, 14 November 2007 - 11:05 PM.


#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 November 2007 - 11:13 PM

The only way to find out is to try... it is a random fact of life.

But since i'm here, if no match is found, it will return 0 results, which is probably something you will have to handle in your code (like with what archangel provided).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users