SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Location
    British Columbia, Canada
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URGENT HELP NEEDED to troubleshoot a page

    All of a sudden a page which hasn't been changed since February 19/12 is no longer working and I can't figure out why. It's a form and is now returning the error:

    "CGI Error
    The specified CGI application misbehaved by not returning a complete set of HTTP headers."

    This is an untouched file which has been working perfectly. A slightly revised copy of the file is still working fine. I've compared the code between the 2 files and can't find anything different (other than the few words on the page which are different - nothing to do with the form fields, which are identical).

    This is the file which doesn't work (it's at http://www.caninereview.ca/directory...ng_order.php):


    <?php require_once('Connections/db9568.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
    {
    if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
    }

    $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
    break;
    }
    return $theValue;
    }
    }

    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
    $insertSQL = sprintf("INSERT INTO people (firstName, lastName, cityName, provName, countryName, phoneNumb, emailAddy, kennelName, breedName, website, Show_Hide, Directory_Listing) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
    GetSQLValueString($_POST['firstName'], "text"),
    GetSQLValueString($_POST['lastName'], "text"),
    GetSQLValueString($_POST['cityName'], "text"),
    GetSQLValueString($_POST['provName'], "text"),
    GetSQLValueString($_POST['countryName'], "text"),
    GetSQLValueString($_POST['phoneNumb'], "text"),
    GetSQLValueString($_POST['emailAddy'], "text"),
    GetSQLValueString($_POST['kennelName'], "text"),
    GetSQLValueString($_POST['breedName'], "text"),
    GetSQLValueString($_POST['website'], "text"),
    GetSQLValueString($_POST['Show_Hide'], "text"),
    GetSQLValueString($_POST['Directory_Listing'], "text"));

    mysql_select_db($database_db9568, $db9568);
    $Result1 = mysql_query($insertSQL, $db9568) or die(mysql_error());

    $insertGoTo = "CRcart/directory_listing_pic.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
    }
    header(sprintf("Location: %s", $insertGoTo));
    }

    mysql_select_db($database_db9568, $db9568);
    $query_rsBreedList = "SELECT breedCode, breedName FROM breeds ORDER BY breedName ASC";
    $rsBreedList = mysql_query($query_rsBreedList, $db9568) or die(mysql_error());
    $row_rsBreedList = mysql_fetch_assoc($rsBreedList);
    $totalRows_rsBreedList = mysql_num_rows($rsBreedList);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <meta name="keywords" content="Canine Review Dog Magazine, dog shows, obedience, agility, rally-o, veterinarian advice, dog magazine, kennels, judges, dog shows, kennel clubs, Top Dogs, purebreds" />
    <meta name="description" content="Canine Review magazine is Canada's oldest independent competitive dog show magazine. It was the first Canadian dog show entity to have a presence on the internet and now we're reaching out to the world as the first dog show entity on mobile devices" />

    <link href="css/CR-2012.css" rel="stylesheet" type="text/css" />



    <title>Canine Review Magazine - Directory Listing Order Form</title>
    <script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
    <link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
    </head>

    <body>

    <?php include("_includes/header.php"); ?>

    <div id="order-directory">

    <form id="DirOrderForm" name="Directory Order Form" method="post" action="">
    <h4>Enter the information for your FREE listing here. Contact your breed club to have then add a listing too!</h4>
    </form>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
    <table align="center">
    <tr valign="baseline">
    <td nowrap="nowrap" align="right"><p>First Name*/p></td>
    <td nowrap="nowrap"><p>
    <input name="firstName" type="text" value="" size="40" maxlength="50" />
    **Last Name*:*
    <input name="lastName" type="text" value="" size="40" maxlength="50" />
    </p></td>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap" align="right"><p>City*/p></td>
    <td nowrap="nowrap"><p>
    <input name="cityName" type="text" value="" size="30" maxlength="30" />
    **Province/State*:
    <input name="provName" type="text" value="" size="20" maxlength="30" />
    *Country*:
    <input name="countryName" type="text" value="" size="30" maxlength="30" />
    *</p></td>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap" align="right"><p>Phone Number/p></td>
    <td><p>
    <input name="phoneNumb" type="text" size="30" maxlength="30" />
    **E-mail Address*:
    <span id="spryEmailDir">
    <input name="emailAddy" type="text" id="spryEmail" size="50" maxlength="50" />
    <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span> </p></td>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap" align="right"><p>Kennel Name*/p></td>
    <td><p>
    <input name="kennelName" type="text" size="50" maxlength="50" />
    **Breed*:

    <select name="breedName" id="BreedList">
    <?php
    do {
    ?>
    <option value="<?php echo $row_rsBreedList['breedName']?>"><?php echo $row_rsBreedList['breedName']?></option>
    <?php
    } while ($row_rsBreedList = mysql_fetch_assoc($rsBreedList));
    $rows = mysql_num_rows($rsBreedList);
    if($rows > 0) {
    mysql_data_seek($rsBreedList, 0);
    $row_rsBreedList = mysql_fetch_assoc($rsBreedList);
    }
    ?>
    </select>
    </p>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap" align="right"><p>Website/p></td>
    <td><p>http://
    <input name="website" type="text" value="" size="100" maxlength="100" />
    </p></td>
    </tr>
    <tr valign="baseline">
    <td align="right" valign="top" nowrap="nowrap"><p>A few words about <br />
    your kennel*<br />
    (500 characters max)/p></td>
    <td>
    <p><span id="spryDirectoryListing">
    <textarea name="Directory_Listing" id="spryDirListing" cols="100" rows="5"></textarea>
    <span id="countsprytextarea1">&nbsp;</span><span class="textareaRequiredMsg">A value is required.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span> </p></td>
    </tr>
    <tr valign="baseline">
    <td nowrap="nowrap" align="right"><p>* Indicates required field*</p></td>
    <td><p>After you

    click &quot;Submit Information&quot; you will be taken to <br />
    a form where you can pay for and send a photo or logo if you so choose*
    <input type="submit" value="Submit Information" />
    </p></td>
    </tr>
    </table>
    <input type="hidden" name="Show_Hide" value="Y" />
    <input type="hidden" name="MM_insert" value="form2" />
    </form>
    <p>&nbsp;</p>

    <!-- order-directory --></div>

    <?php include("_includes/footer.php"); ?>

    <script type="text/javascript">
    var sprytextarea1 = new Spry.Widget.ValidationTextarea("spryDirectoryListing", {maxChars:500, counterId:"countsprytextarea1", counterType:"chars_remaining", validateOn:["blur"]});
    var sprytextfield1 = new Spry.Widget.ValidationTextField("spryEmailDir", "email", {validateOn:["blur"]});
    </script>
    </body>
    </html>
    <?php
    mysql_free_result($rsBreedList);
    ?>

    When I hit the submit button, not only do I get the CGI error mentioned above but the url bar changes to read http://caninereview.ca/directory_lis...ing_order.php? instead of going to the specified page ( $insertGoTo = "CRcart/directory_listing_pic.php", which works perfectly on the _CLUB version of the page.

    Can anyone see what the problem could be?

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you check with your host to see if they made any recent changes to the system?

  3. #3
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Try setting the form action to "directory_listing_order.php"

    I remember having issues with Safari and empty form actions. And I assume you're on Safari since you mentioned MAMP.

    Also just an FYI on forum etiquette, caps don't help you attract others to help you. I realize it may be urgent for you, but this is a free forum, so you have to take what you can get.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Location
    British Columbia, Canada
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry wonshikee - I was (and still am) frantic so wanted to get that across. :>) I do apologize for the caps - I don't generally use them.

    To address your points, I *think* the form action is blank because immediately following it there is another form action type thing. If I were to change the form action from "" to anything, I'd want to change it to go to the 2nd form, where people can upload a photo. I'm kind of chicken to change that sort of thing because I really am not confident with this stuff - I've only been learning it for a little over a week.

    Also, I've tried the form in Safari, Firefox and OmniWeb with exactly the same CGI error and the weird change in the url bar.

    As I mentioned, the *exact same form* with some words changed (ie "enter your club name" instead of "enter your kennel name" - that type of thing) works perfectly. I have literally looked at every character on the non-working page and compared it to every character on the working page and other than the text difference, NONE of the coding appears to be different.

    Thanks also for your comment Litebearer. The answer is yes, they've set up the Zend Framework for me but if that was what's causing the problem, shouldn't BOTH forms stop working, not just one? Neither one has the Zend Framework stuff included - that's in a test file I was playing with so I wouldn't screw up the working one. So much for that theory! :>)

    I'm totally frantic about this. It's been working fine for a week - why stop now?! I have gone back into Time Machine and replaced the current version of the file with the one dated Feb. 19 and even manually uploaded the file to the site (instead of letting DW do it), just in case but it still won't work. I do know that it *has* been working because people have been using it since the 19th.

  5. #5
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    try adding

    exit();

    after the header ();

    another possibility is changing this

    $insertGoTo = "CRcart/directory_listing_pic.php"

    to
    $insertGoTo = "/CRcart/directory_listing_pic.php"

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Location
    British Columbia, Canada
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean like this?

    header(sprintf("Location: %s", $insertGoTo));
    }
    exit();

    or like this:

    header(sprintf("Location: %s", $insertGoTo));
    exit();
    }


    I'm still feeling my way along with coding so am not sure just where it should go. Thanks for the tip though.

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Location
    British Columbia, Canada
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By the way, I forgot to mention the REALLY weird thing. I've been playing around with Zend Framework and have the exact same form working perfectly under a different name. However, when I take that working page (http://www.caninereview.ca/directory...tZendemail.php) and do a Save As to replace the directory_listing_order.php page, the error occurs. It's the same bloody page which works perfectly with the "testZendemail" part in its name. Why on earth would it not work without it??!!!

  8. #8
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Helen W Lee View Post
    Do you mean like this?

    header(sprintf("Location: %s", $insertGoTo));
    }
    exit();

    or like this:

    header(sprintf("Location: %s", $insertGoTo));
    exit();
    }


    I'm still feeling my way along with coding so am not sure just where it should go. Thanks for the tip though.
    The latter is correct. Also when you do a header redirection, you almost always want the exit(); anyway - there's no reason to continue letting PHP process and send to the user.

    Also try my 2nd solution I edited.

  9. #9
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a google search indicates the problem may be related to whether php is installed as a module or as cgi - check with host to see if it was one and now is the other.

  10. #10
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Location
    British Columbia, Canada
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I didn't know I was doing a "header redirection". :>) I am VERY new to this!!

    I've temporarily fixed the problem by simply re-naming the file. It didn't work when I renamed it to directory_listing_order2.php so I changed it completely to directory_listing_entryform.php and it works. Exact same coding - *without* the exit(); bit, as I was waiting for your reply - and it works with a different name. How bizarre is that?!

    Thanks for the edited tip (including the / before CRcart) - I'll keep that in mind.

  11. #11
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Location
    British Columbia, Canada
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks litebearer but wouldn't that also mean that NONE of the forms would work? Not just the one? Also, changing the name shouldn't make it work, should it? This is just SO weird and I appreciate you folks taking the time to help me out.


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
  •