homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

$ GET issues

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

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)

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)

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)

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


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


$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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved