Jump to content

Search engine help....


marklarah

Recommended Posts

I looked at a tutorial which uses "LIKE" but my mysql doesnt like it. My code is

<?
include 'top.php';
$title = "Movie Search";
include 'affs.php';
?>
<head>
<style type="text/css">
a.uppercase {
text-transform: uppercase;
font-size: 17px;
font-weight: bold

}

</style>
</head>
<body>
<?
include 'experiment banner.php';
?>
<center><p>
<?
if (isset($_POST['val'])){
$string = $_POST['val'];

$sql = "SELECT * FROM 2 WHERE `Name` LIKE '$string' ORDER BY `Name` DESC";
$query = mysql_query($sql) or die(mysql_error());
$row_sql = mysql_fetch_assoc($query);
$total = mysql_num_rows($query);

if($total>0) {
$i = "1";
while ($rowd = mysql_fetch_assoc($query)) {

$bob = $rowd['Name'];
$url = $rowd['Link'];
$u = $rowd['ID'];
$v = $rowd['Viewed'];
$r = $rowd['Rating'];

echo '<tr><td><font color="#525757"><b>'.$i.')</b> <a href="log.php?id='.$u.'">'.$bob.'</a> - Viewed <b>'.$v.'</b> times. Rating: '.$r.'<hr></font></td></tr>';
$i++;
}
} else
{
echo "Sorry, no results were found.";
}
}else{
?>
<div align="center">
<br><b><font color="#525757" size="+2">Search for movie in our database:</font></b><br>
<form method="post" action="msearch.php">
<input type="text" name="val"><br> <input type="submit" value="Search!"></form>
</div>
<?
}
?>

 

 

My error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2 WHERE `Name` LIKE 'rock' ORDER BY `Name` DESC' at line 1

 

 

So its a mysql error, meaning it doesn't like the syntax (or most probably LIKE

 

 

Here is some version stuff from cPanel

Apache version 2.2.6 (Unix)

PHP version 5.2.5

MySQL version 5.0.45-community

 

 

Can anyone halp? thanks :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/92668-search-engine-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.