Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 40

Thread: Are Hidden Variables $_POST variables?

  1. #21
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That syntax is correct. Something must be wrong with the variable names (or how it was sent originally). At some point in there, "agency" (in one of its forms) was blank.

    Turn on error reporting to the highest level and you will get warnings when you are calling a variable with no value or an array with a key that does not exist. It will tell you the line number so you can track it that way and find out where it is being lost.

    http://www.php.net/manual/en/functio...-reporting.php

    At the beginning of your script, add:
    // Report all PHP errors
    error_reporting(-1);

    You can also change the setting in php.ini, but this way it will just be there for debugging. Find the errors, fix them, and once the page is ready to go, remove that line again and the users won't see any extra errors (or back to the original setting, at least), so that you can debug but they don't get worrying, confusing notices.

    Though it is always a good idea to fix all errors and notices, some of them do not actually "hurt" anything, but instead just make it confusing because php can guess and work around them. Basically if you use a variable that doesn't exist it will use an empty string instead (why you're getting ''). If you have this kind of problem and then don't show the notices (low level error reporting), then the users won't know the difference and the script will run fine (most likely), but it will be more difficult to debug.
    So, if you turn that on and find many things wrong with the script, then just fix the ones that are actually causing you problems. Then you can remove that code again and it'll go back to how it was. If you have the extra time, fix the extra problems too, but it's not crucial. (More important later if you are expanding the script, or someone else is working on it.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  2. The Following User Says Thank You to djr33 For This Useful Post:

    kuau (01-25-2010)

  3. #22
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Hi traq: I did do the whole thing your way, ie. setting all the $_POST variables to plain variables first, but was desperately trying anything to get it to work.

    $Agency is correct, but good eye that you caught that change. Through this process I discovered that I had been using one variable for two different values and had to introduce $Agency to represent the short name. But you did draw my attention to the possibility that the variable name was wrong and, sure enough, the script that creates the drop-down boxes was still using the old name, so I changed it to $Agency and now everything works like a charm. I'm about to make it live, which is the real test... I'll let you know what happens.

  4. #23
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Hi Nile: I removed that code when things weren't working, but as soon as I have everything live and functioning, I'll reintroduce it and try your addition... thanks!

  5. #24
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Hi Daniel: Great advice, which I will try in a bit. The owner's waiting for me to make it live right now so I have a feeling I'm going to need it very soon haha.

  6. #25
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Miracle of all miracles, I made it all live without a hitch! Thank you guys for all your help... I could never have done this without you. Daniel, I even understand 99% of the code thanks to your great explanations and homework you give me! I still have some modules in the Admin Panel to do, but the main functions are done... yea!!

    After all the modules are done, then I need to try turning Register_Globals off and see how I really did haha. I'm sure it will crash and burn, but it feels good to get this far. Thanks a million for being there. I wish I could give you a big hug.

  7. #26
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    I sure hope you guys are there because I am in a major emergency on the live site. Nothing is working because I am getting this error message but cannot find the error...

    Code:
    Parse error: syntax error, unexpected '=' in /home1/mauiretr/public_html/_car/php/add-agency-logos.php on line 5
    There is no equal sign that seems to be incorrect. Here is the code...

    Code:
    if($selection == "best"){
      sql = "SELECT agency_id, agency, agencyname, logo FROM `agency` WHERE `agency` = $Best_Rental ";
      $result = mysql_query($sql,$connection) or die("Couldn't execute $sql query. <br> mysql error: ".mysql_error());  
      $row = mysql_fetch_array($result);
    } elseif($selection == "all"){
      sql = "SELECT * FROM `agency` WHERE `agency_id` = $_POST['agency_id'] ";
      $result = mysql_query($sql,$connection) or die("Couldn't execute $sql query. <br> mysql error: ".mysql_error()); 
      $row = mysql_fetch_array($result);
    } elseif($source == "cp" || $source == "cancel"){
      sql = "SELECT agency_id, agency, agencyname, logo FROM `agency` WHERE `agency` = '$Agency' ";
      $result = mysql_query($sql,$connection) or die("Couldn't execute $sql query. <br> mysql error: ".mysql_error());  
      $row = mysql_fetch_array($result);
    }
    
    $Best_Rental = $row['agency'];
    $agencyname  = $row['agencyname'];
    $Car_Logo    = $row['logo'];
    Please help before the owner freaks out!!! Thanks. e

  8. #27
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    $sql =

    mistyped twice in your code
    Corrections to my coding/thoughts welcome.

  9. The Following User Says Thank You to bluewalrus For This Useful Post:

    kuau (01-27-2010)

  10. #28
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear bluewalrus:

    OMG! Duh! 3 times actually (from copy and paste). Thank you so much!!! I have been up all night and cannot even see straight.

    Talk about misdirected attention. e

  11. #29
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Parse errors are special: this means that upon the initial scan of your code, the php engine did not know what to do with it. There isn't something "going wrong" as the code is run, but it's actually unintelligible from the beginning. This usually makes it easy to find because it's almost always a typo or misplaced bracket, etc. The only problem is that frequently parse errors don't tell you exactly where to look because it only knows there's a problem when it gets to something it doesn't understand. For example, if you are missing a bracket and it reaches the end it will give an error (unexpected $end) for the last line, regardless of where the actual typo is. Still, though, this makes debugging clearer. Hope that helps next time.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  12. The Following User Says Thank You to djr33 For This Useful Post:

    kuau (01-27-2010)

  13. #30
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Hi Daniel:

    I am really starting to "get" this stuff thanks to your great explanations. Now that the panic's over I can put the code back to the way I like it with the least amount of redundant code. One thing I'm not sure about is when you have to separate the variables from the SQL. Which is the best practices way of saying agency = $Best_Rental;

    Like this? "... WHERE agency = '$Best_Rental' ";
    OR this? "... WHERE agency = ' ".$Best_Rental." ' ";
    OR this? "... WHERE agency = $Best_Rental ";

    Also is "||" exactly equivalemt to "OR" and does it matter if you use one or the other? Any advantages either way? Thanks, e
    Last edited by kuau; 01-27-2010 at 10:36 PM. Reason: added code tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •