• 0

PHP search engine help needed


Question

I'm a neewbie to php and I managed to make a search engine with keywords, but when I want the engine to search from a list menu instead of keywords I get some errors, could someone please explain me what I'm doing wrong ? here is some of the code:

if (($country == "") || ($country == " ")) 

	{
	print ("You have to choose a country to search in");
	exit;	
	}

if (($country <> "") || ($country <> " "))

  $category_query = "SELECT * FROM os_person WHERE (person_country like \"$country%\") AND (person_army like \"$army\") ";

Remember: I'm a neewbie :p :) :) :)

Thanks in advance

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Try this:

<?php
if (($country == "") || ($country == " "))
{
  print ("You have to choose a country to search in");
  exit;
}
else
 $category_query = "SELECT * FROM os_person WHERE (person_country like \"$country%\") AND (person_army like \"$army\") ";
?>

Link to comment
Share on other sites

  • 0

thanks, it looks a lot better using the else statement instead, but I still get a message that says:

Notice: Undefined variable: country in c:\program files\apache group\apache\htdocs\opponentsearch\result.php on line 29

On line 29:

if (($country == "") || ($country == " "))

Thanks in advance

Link to comment
Share on other sites

  • 0

Thats because in the php.ini configuration file you have errors to show to E_ALL.

You can either:

1.Change that in the configuration file.

2. Change in the script with error_reporting(E_ERROR);

The first option is better, since you dont want to show the outside world details about your

scripts, its a security risk.

Now, by the notice, it seems that you must be getting the data in $country from a post or get

method in a form. I stress that after PHP 4.2.1 post and get variables are only available through

the superglobal $_GET[] and $_POST[].

In other words, if you want to get the country, depending on the method that you submitted, you would

apply it like this:

if (($_GET['country'] == "") || ($_GET['country'] == " "))

Hope that clarifies things.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.