I'm having problems with a script that I've been modifying from one I found in an O'Reilly PHP book. I've been trying to add the LIKE parameter to the query. It worked when I used a simple query, but no longer does. The script seems to be running, since it displays the search (I put that line in just to test that the script was doing SOMETHING. The query works fine when I type it directly into MySQL, so I know that isn't the problem. Why isn't it displaying any of the echo statements which are intended to display the results? Thanks a million for any help you can provide.
<?php
include("db_login.php");
$connection = mysql_connect($db_host, $db_username, $db_password );
if (!$connection){
die ("Dould not connect to the database: <br />". mysql_error());
};
$db_select=mysql_select_db($db_database);
if (!$db_select)
{
die("Could not select the database: <br />". mysql_error());
};
$search=$_GET[search];
$query = "select * from main where artist like ('%search%')";
$result = mysql_query($query);
if (!$result)
{
die ("Could not query the database: <br />". mysql_error());
};
while ($result_row = mysql_fetch_row(($result)))
{
echo 'Artist: '.$result_row[1].'<br />';
echo 'Album: '.$result_row[2].'<br />';
echo 'Genre: '.$result_row[3].'<br />';
echo 'Year Released: '.$result_row[4].'<br />';
echo 'Rating: '.$result_row[5].'<br /><hr />';
}
echo $search;
mysql_close($connection);
?>