back2black
Junior Member
- Dec 20, 2008
- 118
- 29
Hi All,
Ive got a page called user.php and when I link to there I get there by sending a URL variable called id.... so basically like this...
user.php?id=6
user.php?id=3 etc etc...
Then in my main code I have a line like this:
For some reason this doesnt work though (i.e. it doesnt display the 'name' field for the given 'id' field).
I know that the problem part of the code is the $result line because when I replace a plain number instead of the $_GET function it displays the 'name' field ok... i.e. this...:
...would display the correct 'name' field.
Any ideas what is wrong with my $GET['id'] field?
Thanks for all your help!
Ive got a page called user.php and when I link to there I get there by sending a URL variable called id.... so basically like this...
user.php?id=6
user.php?id=3 etc etc...
Then in my main code I have a line like this:
Code:
<?php
$result = mysql_query("SELECT * FROM sp_table WHERE id=$_GET['id']");
while($row = mysql_fetch_array($result))
{
echo $row['name'];
echo "<br />";
}
?>
For some reason this doesnt work though (i.e. it doesnt display the 'name' field for the given 'id' field).
I know that the problem part of the code is the $result line because when I replace a plain number instead of the $_GET function it displays the 'name' field ok... i.e. this...:
Code:
$result = mysql_query("SELECT * FROM sp_table WHERE id='1'");
...would display the correct 'name' field.
Any ideas what is wrong with my $GET['id'] field?
Thanks for all your help!