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_listing_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”); ?>

&lt;div id="order-directory"&gt;

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

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

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

&lt;!-- order-directory --&gt;&lt;/div&gt;

<?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_listing_order.php/directory_listing_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?

Did you check with your host to see if they made any recent changes to the system?

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.

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.

try adding

exit();

after the header ();

another possibility is changing this

$insertGoTo = “CRcart/directory_listing_pic.php”

to
$insertGoTo = “/CRcart/directory_listing_pic.php”

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.

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_listing_order-testZendemail.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??!!!

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.

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.

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.

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.