Same code different PHP builds-->problems

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • john

    Same code different PHP builds-->problems

    Hi all.

    I am having a bit of trouble with my site on two different hosting
    platforms.

    Here at work, I am running Mandrake10 Official, but Speakeasy is running
    PHP with different compile options. I've already had to add "_COOKIE"
    and "HTTP_POST_VARS " to my code to allow for this, but something else is
    apparently amiss as well.

    Everything looks fine when testing locally, but from the speakeasy site,
    I get this in all my textboxes:
    <br /><b>Notice</b>: Undefined index: CompFax in
    <b>/mnt/webhosting/sites/d/deluxestitcher. com/order.php</b> on line
    <b>157</b><br />

    It apparently only appears in boxes for which no cookie has been stored
    in the browser.

    Here's the page with problems:


    Could someone please tell me the hopefully quick & easy solution to this?

    Thanks.

    --john

    Here's a small code snippet:
    <font size="2"
    face="Arial,Hel vetica,Geneva,S ans-serif,sans-serif"><b>Compa ny
    Fax:</b></font></div></td>
    <td colspan="8"><di v align="right">< table width="100%" border="0"
    cellspacing="0" cellpadding="0" >
    <tr><td align="left"><i nput id="CompanyFax " value="<?php echo
    $_COOKIE["CompFax"] ?>" type="text" name="CompanyFa x" size="34"
    maxlength="70">
    </td></tr>

    Speakeasy's info.php can be found here:


    My local info.php can be found here:

  • Brion Vibber

    #2
    Re: Same code different PHP builds--&gt;problems

    john wrote:[color=blue]
    > Everything looks fine when testing locally, but from the speakeasy site,
    > I get this in all my textboxes:
    > <br /><b>Notice</b>: Undefined index: CompFax in
    > <b>/mnt/webhosting/sites/d/deluxestitcher. com/order.php</b> on line
    > <b>157</b><br />[/color]
    [snip][color=blue]
    > Could someone please tell me the hopefully quick & easy solution to this?[/color]

    You can use isset() or empty() to make sure that the variables are set
    before using them. Alternatively if you know this is okay you can simply
    disable the notices -- see http://www.php.net/error_reporting
    [color=blue]
    > <tr><td align="left"><i nput id="CompanyFax " value="<?php echo
    > $_COOKIE["CompFax"] ?>" type="text" name="CompanyFa x" size="34"
    > maxlength="70">[/color]

    Be careful here too; if the cookie is set from user-supplied data it
    could break your HTML output if a double-quote or other special
    character is typed. (Consider also the possibilities of malicious
    attacks inserting arbitrary HTML via your forms.) Consider using
    htmlspecialchar s() to escape output.

    -- brion vibber (brion @ pobox.com)

    Comment

    • john

      #3
      Re: Same code different PHP builds--&gt;problems

      Brion Vibber wrote:[color=blue]
      > john wrote:
      >[color=green]
      >> Everything looks fine when testing locally, but from the speakeasy
      >> site, I get this in all my textboxes:
      >> <br /><b>Notice</b>: Undefined index: CompFax in
      >> <b>/mnt/webhosting/sites/d/deluxestitcher. com/order.php</b> on line
      >> <b>157</b><br />[/color]
      >
      > [snip]
      >[color=green]
      >> Could someone please tell me the hopefully quick & easy solution to this?[/color]
      >
      >
      > You can use isset() or empty() to make sure that the variables are set
      > before using them. Alternatively if you know this is okay you can simply
      > disable the notices -- see http://www.php.net/error_reporting[/color]

      That did it. I just added an "if (!empty())" to each $_COOKIE[""] instance.
      [color=blue][color=green]
      >> <tr><td align="left"><i nput id="CompanyFax " value="<?php echo
      >> $_COOKIE["CompFax"] ?>" type="text" name="CompanyFa x" size="34"
      >> maxlength="70">[/color]
      >
      >
      > Be careful here too; if the cookie is set from user-supplied data it
      > could break your HTML output if a double-quote or other special
      > character is typed. (Consider also the possibilities of malicious
      > attacks inserting arbitrary HTML via your forms.) Consider using
      > htmlspecialchar s() to escape output.[/color]

      Actually, just did that as a matter of fact. :) Found a removeEvilTags
      function on the php site.

      Thanks,
      john

      Comment

      Working...