Keep getting error in MySQL query

Zobator

New Member
Hi
When I try to execute the query below I keep getting this error. What's wrong?

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 'Group ON Game.GroupID=Group.GroupID WHERE upper Game.GameNameNL LIKE'%BUSH%'' at line 1


Code:
<?php
$search = mysql_real_escape_string($_POST["search"]);
echo "<h2>Results</h2><p>";
if ($search == "")
{echo "<p>You didn't search for anything";
exit;
}
mysql_connect('localhost:3306', 'root', '') or die(mysql_error());
mysql_select_db("my_database") or die(mysql_error());
$search = strtoupper($search);
$search = strip_tags($search);
$search = trim ($search);
$data = mysql_query("SELECT Game.GameName , Game.GameImgURL , Game.GameHREFNL , Genre.GenreHREFNL , Group.GroupHREFNL FROM Game INNER JOIN Genre ON Game.GenreID=Genre.GenreID INNER JOIN Group ON Game.GroupID=Group.GroupID WHERE upper Game.GameNameNL LIKE'%$search%'") or die(mysql_error());
echo "<b>You searched for:</b> " .$search;
echo "<br>"; echo "<br>";
while($result = mysql_fetch_array( $data ))
{
echo $result['Game.GameNameNL'];
echo " ";
echo $result['Group.GroupHREFNL'];
echo "<br>";
echo $result['Game.GameHREFNL'];
echo "<br>";
echo "<br>";
}
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, we didn't find anything<br><br>";
}
?>
 

leroy30

New Member
I'm an ASP.net / MSSQL guy so I don't know enough about PHP / MySQL to truly help out but is it neccessary to have "localhost:3306"? I would have thought "localhost" would point to your MySQL database if it is running on your local computer.

Also check that the database server (localhost) actually IS running ;o)
But I'm sure you have.

Hope you work it out!
 
Top