I am developing a similar site on my laptop (Ubuntu/Apache/Mysql) now and the script does nothing, it returns nothing at all no matter what I search for.
Can anyone give me an idea of where I can begin to research to find out why it will not respond on one server yet runs fine on another.
Code: Select all
<form name="search" method="post" action="<?=$PHP_SELF?>">
Seach for: <input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="name">Name</option>
<Option VALUE="contact">Contact</option>
<Option VALUE="phone">Phone</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
<?php
//This is only displayed if they have submitted the form
if ($searching =="yes")
{
echo "<h2>Results for: $find </h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// Otherwise we connect to our Database
mysql_connect("localhost", "sqluser", "sqlpasswd") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM table WHERE upper($field) LIKE'%$find%'");
//And we display the results
while($result = mysql_fetch_array( $data ))
{
$name = $result['name'];
$contact = $result['contact'];
$altcontact = $result['altcontact'];
$address = $result['address'];
$phone = $result['phone'];
$fax = $result['fax'];
$cell = $result['cell'];
$altphone = $result['altphone'];
$current = $result['current'];
$destination = $result['destination'];
$special = $result['Special'];
echo "<table width=1200 border=1>";
echo "<tr><td width=50%><b> $name </td><td><b>Special Instructons:</td></tr>";
echo "<tr><td><b>Contact:</b> $contact <br>";
echo "<b>Alt. Contact:</b> $altcontact <br>";
echo "<b>Address:</b> $address <br>";
echo "<b>Phone:</b> $phone";
echo "<b>Fax:</b> $fax";
echo "<b>Cell:</b> $cell <br>";
echo "<b>Email:</b> $altphone <br>";
echo "<b>Currently Using:</b> $current<br>";
echo "<b>Destinations:</b> $destination<br>";
echo "<td> $special </tr></td>";
echo "<br>";
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
//And we remind them what they searched for
echo "<b>Searched For:</b> " .$find;
}
}
?>