6 Replies - 698 Views - Last Post: 14 December 2012 - 04:27 PM Rate Topic: -----

#1 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 23
  • View blog
  • Posts: 326
  • Joined: 11-July 07

No GET variables, thanks to Apache

Posted 02 December 2012 - 04:11 PM

Hello, D.I.C.

I don't know if this is in the correct forum, but I should assume so since my primary language is in PHP.

I'm using mod_rewrite to make my URL's look a little more prettier than what they would be without it. Since using them, I can't seem to pass any $_GET variables - they just don't pass all together.

In my PHP document, I'm debugging using: <?php foreach ( $_GET as $g => $d ) { echo "{$g} = {$d}<br />"; } ?> and the only parameters which are being passed are those specified in my .htaccess - if I use the address bar to input a get variable, the debugging code doesn't print anything else out, only the aforementioned.

Am I doing something wrong? I hope it's a quick fix and I'm just being a plonker.

Thanks in advanced, always appreciated.

~huzi

Is This A Good Question/Topic? 0
  • +

Replies To: No GET variables, thanks to Apache

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3511
  • View blog
  • Posts: 10,136
  • Joined: 08-June 10

Re: No GET variables, thanks to Apache

Posted 02 December 2012 - 04:14 PM

since you rewrite the URL before it reaches the PHP interpreter, only those from rewriting are received. if you have additional parameters that ain’t passed along in the .htaccess as well, they’re gone.
Was This Post Helpful? 0
  • +
  • -

#3 Groudon  Icon User is offline

  • New D.I.C Head

Reputation: -18
  • View blog
  • Posts: 33
  • Joined: 01-December 12

Re: No GET variables, thanks to Apache

Posted 02 December 2012 - 07:48 PM

Use this -
<?php echo '$_GET['your value'];' ?>

Was This Post Helpful? -6
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3511
  • View blog
  • Posts: 10,136
  • Joined: 08-June 10

Re: No GET variables, thanks to Apache

Posted 03 December 2012 - 02:33 AM

View PostGroudon, on 03 December 2012 - 03:48 AM, said:

Use this -
<?php echo '$_GET['your value'];' ?>

syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, etc. pp.
Was This Post Helpful? 0
  • +
  • -

#5 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 23
  • View blog
  • Posts: 326
  • Joined: 11-July 07

Re: No GET variables, thanks to Apache

Posted 14 December 2012 - 04:09 PM

View PostGroudon, on 03 December 2012 - 02:48 AM, said:

Use this -
<?php echo '$_GET['your value'];' ?>


I feel insulted by this reply. If I was just having trouble retrieving a value from the GET array, I'd simply debug, like so:
<?php
foreach ( $_GET as $key => $data ) {
     echo '$_SERVER["'.$key.'"] = "'.$data.'";<br />'.PHP_EOL;
}
?>



However, this isn't my problem - it's a little more complex than that. And for your unhelpful post, I have given you minus 1 reputation, along with the others.

Thanks for your replies

~huzi
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3511
  • View blog
  • Posts: 10,136
  • Joined: 08-June 10

Re: No GET variables, thanks to Apache

Posted 14 December 2012 - 04:21 PM

View Posthuzi8t9, on 15 December 2012 - 12:09 AM, said:

If I was just having trouble retrieving a value from the GET array, I'd simply debug, like so:

some slightly faster ways for that (in descending order for debugging usefulness):
* var_dump($_GET);
* var_export($_GET);
* print_r($_GET);

PS. I wouldn’t print $_SERVER for $_GET, some keys may turn out misleading (i.e. $_GET is user-provided, $_SERVER not).
Was This Post Helpful? 1
  • +
  • -

#7 huzi8t9  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 23
  • View blog
  • Posts: 326
  • Joined: 11-July 07

Re: No GET variables, thanks to Apache

Posted 14 December 2012 - 04:27 PM

View PostDormilich, on 14 December 2012 - 11:21 PM, said:

View Posthuzi8t9, on 15 December 2012 - 12:09 AM, said:

If I was just having trouble retrieving a value from the GET array, I'd simply debug, like so:

some slightly faster ways for that (in descending order for debugging usefulness):
* var_dump($_GET);
* var_export($_GET);
* print_r($_GET);

PS. I wouldn’t print $_SERVER for $_GET, some keys may turn out misleading (i.e. $_GET is user-provided, $_SERVER not).


Those are possible alternatives :)

I didn't mean to put $_SERVER, just getting ready for bed - I think it's time.

~huzi
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1