-2

I am trying to pass a variable to PHP page using URL GET but I get blank space, what is wrong?!

url: http://localhost:2651/index_main.php?teamName=Liverpool

here is the destination PHP file:

<?php
  $teamName = $_GET['teamName'];
?>
<html>
<body>
<?php
$searchQuery = $api->searchTeam(urlencode('<?php $_GET["teamName"]; ?>')) // here must get the team name from previous page
?>
<h3>All home matches of <?php echo $team->_payload->name; ?>:</h3>
</body>
</html>
Isabella
  • 137
  • 12
  • If by blank space you mean the [white screen of death](http://stackoverflow.com/questions/1475297/phps-white-screen-of-death), please, [check for errors](http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – FirstOne Aug 04 '16 at 12:52
  • A blank page usually means you have a problem but error_reporting is turned off. [See here for how to turn reporting on](http://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – castis Aug 04 '16 at 12:52
  • `$searchQuery = $api->searchTeam(urlencode(''))` you did close that off, right? If not, then it's a parse error and risks on being closed because of it. – Funk Forty Niner Aug 04 '16 at 12:54
  • What "blank space"? What is the *actual output*? Note that you're not outputting the URL value at all, but instead the result of some other operation we know nothing about. Instead of assuming that PHP's use of a query string is broken, *maybe* look into the possibility that this other complex operation in your code *might* be the problem? – David Aug 04 '16 at 12:54
  • Where is `$team` defined? – FirstOne Aug 04 '16 at 13:02
  • @FirstOne The OP seems to have since ran back into their rabbit hole; gave up on it. Coffee's getting ready too, so I can't miss the ultimate water's boiling point. – Funk Forty Niner Aug 04 '16 at 13:03
  • Solved by ac.freelancer – Isabella Aug 04 '16 at 13:04
  • @Isabella That person added a missing semi-colon (and stuff). You sure that all that was missing in your code? You never bothered answering to any comments left under your question. I love it when someone just keeps us all hanging. – Funk Forty Niner Aug 04 '16 at 13:05
  • I 'v added it, thank you all :) – Isabella Aug 04 '16 at 13:07
  • lol.. I'm outta here.,. @Fred-ii- I suggest you to let go and do the same.. (This comment will be gone soon) – FirstOne Aug 04 '16 at 13:07
  • 1
    @FirstOne I've a good mind to close it as a parse error http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them which is most likely the case here, given the comment about *"I've added it"* about my comment for the missing semi-colon which I feel is all that was wrong here. – Funk Forty Niner Aug 04 '16 at 13:09

1 Answers1

2

First, your code is not clean, you use too many php tags. Here is your code now :

<html>
<head>

</head>
<body>
    <?php
    $teamName = $_GET['teamName'];
    $searchQuery = $api->searchTeam(urlencode($teamName)); // here must get the team name from previous page
    ?>
    <h3>All home matches of <?php echo $team->_payload->name; ?>:</h3>
</body>
</html>

Second, in your urlencode, you put additional php tags and you didn't use the variable you just set before.

FirstOne
  • 6,033
  • 7
  • 26
  • 45
ac.caron
  • 97
  • 1
  • 9