Page 1 of 1

Problem with parsing varible

Posted: Fri Feb 13, 2004 9:01 am
by nutstretch
I am problems with obtaining a variable form the previous page.
I am being told "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 '' at line 1"

Here is the code which triggers the action

print "<td><a href = 'search.php?id=$style'><img src='$test' width='128' height='85' alt='Click here to see more info on this shoe'></a></td>";


The code on the second page is

$style = $_GET["$style"];
$sql = "SELECT * FROM tblShoestest where StyleID like $style";

$resultID = mysql_query($sql, $linkID)or die(mysql_error());

Am i asking for the wrong thing? should i be asking for id?

What I want to happen is then the picture is clicked on, the next page goes and does a query to find out more and display

Any help appreciated

Posted: Fri Feb 13, 2004 9:07 am
by markl999
$style = $_GET['style'];

or just do
$sql = "SELECT * FROM tblShoestest where StyleID like {$_GET['style']}"; then you don't have to create the temporary $style var.

Posted: Fri Feb 13, 2004 9:11 am
by twigletmac
and don't forget to put quotes around strings in SQL:

Code: Select all

$sql = "SELECT * FROM tblShoestest WHERE StyleID='{$_GET['style']}'";
Mac