Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Simple problem with $_GET
Old 05-28-2009, 02:24 PM Simple problem with $_GET
vandtekor's Avatar
Junior Talker

Posts: 4
Name: Oli Loftus
Trades: 0
Hi,

I'm really sorry if I am being stupid here, but I am pulling my hair out. It's these little things that I can't track down, but here goes.

I have the following code, that simply is to assign the value of the $_GET to the variable $paperid.... but it doesn't work!

Code:
if(isset($_GET["id"]))
  $paperid = $_GET["id"];
  echo("$paperid");
I can do this:

Code:
if(isset($_GET["id"]))
//  $paperid = $_GET["id"];
  echo($_GET["id"]);
Which baffles me, as the 2nd line HAS to be commented for that to work.

Any help is really appreciated. I feel like a dunce

Many thanks!
vandtekor is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-28-2009, 02:45 PM Re: Simple problem with $_GET
Super Talker

Posts: 134
Trades: 0
like this maybe

PHP Code:
if(isset($_GET["id"])){
  
$paperid $_GET["id"];
  echo(
"$paperid"); } 
__________________

Please login or register to view this content. Registration is FREE

Check out the Facebook Clone build with Jcow SNS at
Please login or register to view this content. Registration is FREE
, it is free and it always will be
Falcone is offline
Reply With Quote
View Public Profile
 
Old 05-28-2009, 02:55 PM Re: Simple problem with $_GET
vandtekor's Avatar
Junior Talker

Posts: 4
Name: Oli Loftus
Trades: 0
Yes it is confirmed... I am a dunce. The curley parenthesis fixed it.

Thank you so much for the quick reply, it really is appreciated
vandtekor is offline
Reply With Quote
View Public Profile
 
Old 05-28-2009, 03:19 PM Re: Simple problem with $_GET
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Just to clarify, if you are going to use an if (or any other control flow) statement without braces, the body of the statement must consist of only one line:
PHP Code:
//correct
if($conditional)
      echo 
'my output';

//incorrect
if($conditional)
     
$x 1;
     echo 
$x;

//correct
if($conditional)
{
     
$x 1;
     echo 
$x;

__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 05-28-2009, 03:21 PM Re: Simple problem with $_GET
vandtekor's Avatar
Junior Talker

Posts: 4
Name: Oli Loftus
Trades: 0
Ah... ok, that if great info. I'm new to PHP, and not a programming genius in any sense.

Thanks for the info!
vandtekor is offline
Reply With Quote
View Public Profile
 
Old 05-28-2009, 03:31 PM Re: Simple problem with $_GET
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Also, It's a lot more efficient to do the following:

PHP Code:
if(isset($_GET["id"])){
  
$paperid $_GET["id"];
  echo(
$paperid); // Not to put " when returning a string
}  

// For example (Slow/possibly dangerous Way):
echo ("$variable is better then $othervariable");

// Better way
echo ($variable.'is better then'.$othervariable); // The single quote will not execute what is within it, so it's a little faster there also. 
But yeah, use braces when coding it makes it easier when it comes to debugging also.
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Reply     « Reply to Simple problem with $_GET
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23543 seconds with 12 queries