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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.