#!c:/perl/bin/perl.exe
use DBI;
$,="\t";
use CGI ":standard";
$search=param("search");
print"content-type:text/html\n\n";
print"<html>\n";
print"<body bgcolor=\"fffbec\">";
print"<center><b><font face=\"Comic Sans Ms\"><font size=\"6\"><font color=\"990000\"> Search results</b></font face></font size></font color></center><br><br>";
print"<b>You asked for <font color=\"990000\">$search</font color>. Here is the result:</b><br><br>";
$db=DBI->connect("dbi:mysql:Web");
$equery="select eventname,host,venue,standingmin,price from EVENT WHERE eventname='$search'¦¦host='$search' ¦¦venue='$search'¦¦standingmin='$search'¦¦ price='$search'";
$e=$db->prepare($equery);
$e->execute();
print"<br><br><br><br><ul><li><b>Event details</b></li></ul><table border=\"1\" bgcolor=\"yellow\" width=\"60%\"><tr><td align=\"center\"><b>Name</b></td><td align=\"center\"><b>Host</b></td><td align=\"center\"><b> Venue</td><td align=\"center\"><b>Standinmin</b></td><td align=\"center\"> <b>Price</b></td><td align=\"center\"></td></tr>";
while(@eresult=$e->fetchrow())
{print"<tr>";
for($index=0;$index<@eresult;$index++)
{
print "<td align=\"center\">$eresult[$index]</td>";
}
print"</tr>";
}
print"</table>";
Everything works fine until I added ¦¦$price='$search' where suddenly records that do not correspond at all with the word entered are displayed. Could anyone explain why this can be the case?
Thank you
[Sun May 04 16:08:43 2003] [error] [client 127.0.0.1] <- prepare('select eventname,host,venue,standingmin,price from EVENT WHERE eventname='spiky'¦¦host='spiky'¦¦venue='spiky'¦¦standingmin='spiky'¦¦price=spiky' CODE)= DBI::st=HASH(0x369fdc) at search.pl line 59., referer: [localhost...]
I think the problem comes when the price in the database is 0. Any other price behaves properly and are only displayed when they correspond to the word entered whereas the prices that are 0 are always displayed even when they are totally unrelated to the word entered. Is there a special way of dealing with these null values?