Simple PHP script doesn't work with new web host

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • usenet@nathankerr.co.nz

    Simple PHP script doesn't work with new web host

    Hi,

    I have a simple php script which takes a variable from the url and
    prints it out. I've recently changed linux cpanel/whm severs and it no
    longer runs. What modules do I need to install/how do I get it running
    again?

    The script is shown below:

    Example url:



    The following code is in the <headof the php file:

    <?php
    $qsdata = split("&", $QUERY_STRING);
    foreach( $qsdata as $pair ) {
    $kv = split("=", $pair);
    $QS[$kv[0]] = rawurldecode($k v[1]);
    }
    ?>

    The following code is in the <bodyof the php file where a variable
    needs to be printed out:

    <?php print "$QS[variable]"; ?>

    Thanks for your help,

    Nathan.

  • Hendri Kurniawan

    #2
    Re: Simple PHP script doesn't work with new web host

    usenet@nathanke rr.co.nz wrote:
    Hi,
    >
    I have a simple php script which takes a variable from the url and
    prints it out. I've recently changed linux cpanel/whm severs and it no
    longer runs. What modules do I need to install/how do I get it running
    again?
    >
    The script is shown below:
    >
    Example url:
    >

    >
    The following code is in the <headof the php file:
    >
    <?php
    $qsdata = split("&", $QUERY_STRING);
    foreach( $qsdata as $pair ) {
    $kv = split("=", $pair);
    $QS[$kv[0]] = rawurldecode($k v[1]);
    }
    ?>
    >
    The following code is in the <bodyof the php file where a variable
    needs to be printed out:
    >
    <?php print "$QS[variable]"; ?>
    >
    Thanks for your help,
    >
    Nathan.
    >
    Change $QUERY_STRING to $_SERVER['QUERY_STRING']
    better yet try the following:
    <?php
    var_dump($_GET['variable']); // Dump request query "variable"
    var_dump($_GET) ; // Dump all request query
    ?>

    Hendri Kurniawan

    Comment

    • Toby Inkster

      #3
      Re: Simple PHP script doesn't work with new web host

      usenet wrote:
      <?php
      $qsdata = split("&", $QUERY_STRING);
      foreach( $qsdata as $pair ) {
      $kv = split("=", $pair);
      $QS[$kv[0]] = rawurldecode($k v[1]);
      }
      ?>
      Replace this with:

      <?php $QS=$_GET; ?>

      Hint: PHP already includes an array equivalent to your $QS array. It's
      called $_GET.

      --
      Toby A Inkster BSc (Hons) ARCS
      Contact Me ~ http://tobyinkster.co.uk/contact

      Comment

      Working...