homepage Welcome to WebmasterWorld Guest from 174.129.76.87
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
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
jay7981

5+ Year Member



 
Msg#: 3931349 posted 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

http://example.com/page.php?gid=1

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


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

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?

 

d40sithui

5+ Year Member



 
Msg#: 3931349 posted 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());

jay7981

5+ Year Member



 
Msg#: 3931349 posted 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

d40sithui

5+ Year Member



 
Msg#: 3931349 posted 2:53 pm on Jun 12, 2009 (gmt 0)

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

nick279

5+ Year Member



 
Msg#: 3931349 posted 3:32 pm on Jun 12, 2009 (gmt 0)

jay7981


die($sql);
$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