KyleVA Posted April 16, 2009 Share Posted April 16, 2009 Alright, I have two pages within the same directory. test.htm <body> <a href="test.php?data1=Test">Test</a> </body> test.php <body> <?php $data1 = $_get['data1']; ?> </body> It simply displays nothing on test.php - any ideas as to why this won't work? Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/ Share on other sites More sharing options...
mrMarcus Posted April 16, 2009 Share Posted April 16, 2009 echo $data1; Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811690 Share on other sites More sharing options...
dennismonsewicz Posted April 16, 2009 Share Posted April 16, 2009 try this <?php $data1 = $_GET['data1']; echo $data1; ?> Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811691 Share on other sites More sharing options...
mrMarcus Posted April 16, 2009 Share Posted April 16, 2009 oh ya, and $_GET must be capitalized .. looked right past that. Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811695 Share on other sites More sharing options...
PFMaBiSmAd Posted April 16, 2009 Share Posted April 16, 2009 $data1 = $_GET['data1']; is an assignment statement. The output to the browser by the original code is <body></body>. What were you expecting to be displayed? Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811698 Share on other sites More sharing options...
KyleVA Posted April 16, 2009 Author Share Posted April 16, 2009 echo $data1; try this <?php $data1 = $_GET['data1']; echo $data1; ?> Both of you, worked like a charm. I appreciate the quick response, I'm new to PHP so maybe you guys can assist me with problems in the future. :thumbs up: $data1 = $_GET['data1']; is an assignment statement. The output to the browser by the original code is <body></body>. What were you expecting to be displayed? Ahh, makes sense - the $_GET tells the browser to grab the information from the URL and the echo displays it. When is it appropriate to use print vs echo? Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811703 Share on other sites More sharing options...
GingerRobot Posted April 16, 2009 Share Posted April 16, 2009 Ahh, makes sense - the $_GET tells the browser to grab the information from the URL and the echo displays it. When is it appropriate to use print vs echo? For the most part, use which ever you prefer. See this discussion (linked to from the php manual) : http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811715 Share on other sites More sharing options...
mrMarcus Posted April 16, 2009 Share Posted April 16, 2009 echo $data1; try this <?php $data1 = $_GET['data1']; echo $data1; ?> Both of you, worked like a charm. I appreciate the quick response, I'm new to PHP so maybe you guys can assist me with problems in the future. :thumbs up: $data1 = $_GET['data1']; is an assignment statement. The output to the browser by the original code is <body></body>. What were you expecting to be displayed? Ahh, makes sense - the $_GET tells the browser to grab the information from the URL and the echo displays it. When is it appropriate to use print vs echo? perhaps you should read up a little on echo and print. Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811716 Share on other sites More sharing options...
KyleVA Posted April 16, 2009 Author Share Posted April 16, 2009 Will read up on it. Any recommended reads? Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811718 Share on other sites More sharing options...
PFMaBiSmAd Posted April 16, 2009 Share Posted April 16, 2009 The light-blue text in the posts were links to the manual sections. The php manual should be your first stop to answer many of the "what/how" php questions. Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811726 Share on other sites More sharing options...
Maq Posted April 16, 2009 Share Posted April 16, 2009 Just Google, "php echo vs print". Haven't read this article yet but it looks informative. PHP Echo vs Print Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-811735 Share on other sites More sharing options...
dennismonsewicz Posted April 23, 2009 Share Posted April 23, 2009 well in the big scheme of things echo is a little faster when computing the code Quote Link to comment https://forums.phpfreaks.com/topic/154383-http-get-not-working/#findComment-817484 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.