Hi,

I have recently made a listings databse:

http://www.theogb.com/listings

Now, for various reasons I have used a combination of POST variables in forms and also sending variables through the URL in the time honoured manner of:

http://www.theogb.com/listings/giglisting.php?year=2005&month=08&day=10&toyear=2005&tomonth=09&today=10&orderBy=2

Now, currently you can see it's residing at http://www.theogb.com/listings but I am moving it to http://www.ishotthedeputy.com/listings. Both sites are hosted with the same people, but I Shot the Deputy contains Drupal at the root, a PHP/MySQL CMS.
http://www.ishotthedeputy.com

Now I know for a fact that this uses a similar URL variable passing system for reorganising its views of tables.

However, if you go to http://ishotthedeputy.com/listings and click the 'venue' link on the table on the home page, you'll see a load of variables passed through on the URL but they don't make it to the other function: it's not reading them. I know posting works but it's variables like this that don't.

Now there are three posibilities I can think of:

1) It's because I am using the line:
ini_set("session.save_handler", "files");
before my call to:
session_start();
I have to use this because on the I Shot the Deputy site the .htaccess file sets session.save_handler to 'user'. It does this (I presume) because Drupal requires it so I can't delete that line. However, on my home PC this doesn't affect the sending of variables and in fact my website functions perfectly. So what gives?

2) There are a number of different settings in my .htaccess file on http://www.ishotthedeputy.com. I don't know if any of them could be causing it. However, here are the PHP Info links for each server:
http://www.theogb.com/archive/test.php
http://www.ishotthedeputy.com/listings/test.php

3) It's a version problem. Did 4.3.11 correct something that 4.3.10 and earlier allowed through? My home PC system has PHP 4.3.0 (I think)

Errr...

If anyone can help me to understand how to get around this, I would be eternally grateful.

Thanks a lot
Theo

    This is all mute without seeing the code. Have register_globals be off for security reasons and program accordingly. Basically, you should be using $GET to retrieve values from the URL and $POST for form values passed through your HTML form. Are you doing this?

    When building variables in the URL use urlencode():
    http://us2.php.net/manual/en/function.urlencode.php

    or use http_build_query() which does a urlencode() too:
    http://us2.php.net/manual/en/function.http-build-query.php

    The "session.save_handler" has nothing to do with why fields in the URL are not showing up.

      I had no idea there was a special way to encode like that - cheers. I have simply been sending through manually.

      I am using POST (actually I'm using the older $HTTP_POST_VARS['____'] form) to retrieve everything from my forms. As I say, these values are coming through perfectly.

      I've not tried $_GET so I'll have a trawl through the book I've been using to put most of this together.

      I think what confuses me, though, is why it should fail to work in this instance. I think the $_GET sounds like the key to this, then. As you've pointed out, Register Globals is off on my I Shot the Deputy site. I'll try turning it off on TheoGB and see if I have the same issue.

      Cheers.

        When one has PHP version 4.1.0 or higher it's best to use $GET and $POST instead of their $HTTP_xxx_VARS equivalent.

        Please note that if you are trying to use $HTTP_GET_VARS inside a function, then you must use the global keyword. The $HTTP_xxx_VARS are not superglobal like the $GET and $POST.

        See manual page for more info:
        http://us3.php.net/reserved.variables#reserved.variables.get

        // For PHP versions less than 4.1.0
        function a_name () {
            global $HTTP_GET_VARS;
        
        echo $HTTP_GET_VARS['index'];
        }
        
        // For PHP versions 4.1.0 and higher
        function a_name () {
        
        echo $_GET['index'];
        }
        

          Cheers. The older form was used in the code in the book I was using. So I didn't really get round to changing it as I was just trying to get my structure working. I guess they were writing for backward compatibility as it came with PHP 4.3, but the new version now works with version 5.0.

            Okay, thanks. I adjusted the variables to the proper modern form and used $_GET and it's all hunky dory.

            Cheers.

              Write a Reply...