Hi,
I have a site up on the net that is a resource for all things technical!! It lists hundreds of IT related companies that are available for search using two drop down lists.
I have recently added a very simple keyword search (I'm a newbie and this is my first site using PHP and MySQL)
I am using the following code:
<table width=80% align=center>
<?php
mysql_pconnect('localhost','root','');
mysql_select_db('gmarch_support');
$result = mysql_query("SELECT * FROM keyit WHERE comment LIKE '%{$_REQUEST['search']}%' or
company LIKE '%{$_REQUEST['search']}%' or type LIKE '%{$_REQUEST['search']}%' order by
company LIMIT 0,10"
if(mysql_num_rows($result) == 0) {
echo 'Sorry, no results were found';
} else {
while($row = mysql_fetch_row($result)) {
$akey = $row[0];
$company = $row[1];
$type = $row[2];
$web = $row[3];
$comment = $row[4];
echo "<tr><td><a href='$web'><font size=2 face=Verdana, Arial, Helvetica, sans-serif
color=#003366><b>$company</b></font></a></td></tr>";
echo "<tr><td><font size=2 face=Verdana, Arial, Helvetica, sans-serif
color=#003366>$comment</font></td></tr>";
}
}
?>
</table>
At first this appears to work fine but when testing it I typed in "software" without the quotes and the first result is not a company (as it should be) but a string of text.
If you click on this you get a directory listing of our search directory which exposes our database.inc file so our db password!
This only happens when searching using keyword software.
For now I have placed an index.html file in the search directory to stop this until I can fix the problem.
The page can be viewed on the web at:
Can anyone tell me why this is happening?
I'm very confused!!
Thankyou,
Rachel
I have a site up on the net that is a resource for all things technical!! It lists hundreds of IT related companies that are available for search using two drop down lists.
I have recently added a very simple keyword search (I'm a newbie and this is my first site using PHP and MySQL)
I am using the following code:
<table width=80% align=center>
<?php
mysql_pconnect('localhost','root','');
mysql_select_db('gmarch_support');
$result = mysql_query("SELECT * FROM keyit WHERE comment LIKE '%{$_REQUEST['search']}%' or
company LIKE '%{$_REQUEST['search']}%' or type LIKE '%{$_REQUEST['search']}%' order by
company LIMIT 0,10"
if(mysql_num_rows($result) == 0) {
echo 'Sorry, no results were found';
} else {
while($row = mysql_fetch_row($result)) {
$akey = $row[0];
$company = $row[1];
$type = $row[2];
$web = $row[3];
$comment = $row[4];
echo "<tr><td><a href='$web'><font size=2 face=Verdana, Arial, Helvetica, sans-serif
color=#003366><b>$company</b></font></a></td></tr>";
echo "<tr><td><font size=2 face=Verdana, Arial, Helvetica, sans-serif
color=#003366>$comment</font></td></tr>";
}
}
?>
</table>
At first this appears to work fine but when testing it I typed in "software" without the quotes and the first result is not a company (as it should be) but a string of text.
If you click on this you get a directory listing of our search directory which exposes our database.inc file so our db password!
This only happens when searching using keyword software.
For now I have placed an index.html file in the search directory to stop this until I can fix the problem.
The page can be viewed on the web at:
Can anyone tell me why this is happening?
I'm very confused!!
Thankyou,
Rachel