PDA

View Full Version : need help with error


jarv
07-19-2008, 08:50 PM
my error message reads:

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 'Green' at line 1
SQL: SELECT * FROM Pubs WHERE rsTown=Bethnal Green


$r_name = $_GET['spubs'];

$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT * FROM pubs WHERE rsPubname LIKE '%".$r_name."%' ORDER BY rsPubname Asc LIMIT $offset, $rowsPerPage";
$result = mysql_query($query) or die(mysql_error().'<br>SQL: ' . $query);


can someone please help me here?

Nightfire
07-20-2008, 04:51 AM
That error isn't for the code you showed. The error is for the query getting the town, not the pub which you've showed.

The problem is the space in the town's name, so you'll need to add quotes around there...
$query = "SELECT * FROM Pubs WHERE rsTown='" .$town. "';