Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

$ GET issues



3:43 pm on Jun 11, 2009 (gmt 0)

5+ Year Member

i have a link and in the link i have a var that i want passed to the linked page, the link looks like this ...

<a href='./page.php?gid=$array[id]'>

Now i have this link in a mysql query, and this part to my knowledge is working great ... i hover link and the array is placing the correct data, meaning when i hover i see


now on the page.php i have another mysql statement that is setup like this

$gid = $_GET['gid'];
$sql = "SELECT * FROM `table` WHERE `id` = '$gid'" or die('<br />Select Table-'. mysql_error());
$result=mysql_query($sql) or die("<br />Result-". mysql_error());

when this page is displayed its blank, however if i change `id` = '$gid'" to `id` = '1'" it displays fine... so i know the page is formatted right its just not receiving the var correctly... WHY?


4:04 pm on Jun 11, 2009 (gmt 0)

5+ Year Member

Print out your original query with id=$gid. Looks like the single quotes are making the $gid not being evaluated. You do not need quotations around field names or integer values inside a query. Also, you do not need the "or die" piece to $sql, since at this point it is only a string.

$sql = "SELECT * FROM TABLE WHERE id=$gid";
$result = mysql_query($sql) or die("<br />Result-". mysql_error());


4:20 pm on Jun 11, 2009 (gmt 0)

5+ Year Member

your code supplies this error...

Result-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


2:53 pm on Jun 12, 2009 (gmt 0)

5+ Year Member

Odd. Can you print out the entire script? or at least the relevant part?


3:32 pm on Jun 12, 2009 (gmt 0)

5+ Year Member


$result = ....

before the $result, you should see if your query is properly formatted.

run the outputted sql code in phpmyadmin/navicat etc and see if it works


Featured Threads

Hot Threads This Week

Hot Threads This Month