HELP! Apache dies on regular MySQL query :-/

From: Date: Sat, 20 Mar 2004 15:08:52 +0000
Subject: HELP! Apache dies on regular MySQL query :-/
Groups: php.general 
Request: Send a blank email to php-general+get-181028@lists.php.net to get a copy of this message
Okay ... I've run into the strangest error situation. Running Apache 2.0.48 on WinXP Pro SP1, and just upgraded PHP from 4.2.3 to 4.3.0 and didn't do anything but to delete the 4.2.3 binaries and replace them with the 4.3.0 binaries. Problem is I get this error message: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster@metalbunny.net and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. ---------- Apache/2.0.48 (Win32) Server at localhost Port 80 The log says this: [Sat Mar 20 15:54:56 2004] [error] [client 127.0.0.1] Premature end of script headers: php.exe The script that causes this looks like this: require('sql.php'); $link = mysql_connect($dbhost,$dbuser,$dbpass) or die('Could not connect : '.mysql_error()); // echo('Connected successfully'); mysql_select_db($database) or die('Could not select database'); function stripAccents($string) { $returnString = strtr($string,
      'àáâãäçèéêëìíîïñòóôõöšùúûüýÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕ֊ÙÚÛÜÝ', 'aaaaaceeeeiiiinooooosuuuuyAAAAACEEEEIIIINOOOOOSUUUUY');
// $returnString = str_replace('æ','ae',str_replace('Æ','AE',$returnString)); $returnString = str_replace("'",'',$returnString); return $returnString; } $updated = 0; $totalupd = 0; for ($i = ord("a"); $i < ord("z")+1; $i++) { echo('<b>Working on '.strtoupper(chr($i)).'</b><br>'); // commenting out this query makes the error go away, but then the script fails of course $query = mysql_query("SELECT * FROM girlz WHERE lastname LIKE '".chr($i)."%' ORDER BY lastname ASC"); $numrows = mysql_num_rows($query); echo('<b>Loaded/working on '.$numrows.' rows</b><br>'); $updated = 0; while ($row = mysql_fetch_array($query)) {
    $girlID = $row['ID'];
    $lastname = $row['lastname'];
    $firstname = $row['firstname'];
    $middlename = $row['middlename'];
    $firstsort = stripAccents(html_entity_decode($firstname),ENT_QUTES);
    $middlesort = stripAccents(html_entity_decode($middlename),ENT_QUOTES);
    $lastsort = stripAccents(html_entity_decode($lastname),ENT_QUOTES);
    echo("<font color=\"#0000ff\">$firstname $middlename $lastname</font>");
    echo("<font color=\"#800000\">$firstsort $middlesort $lastsort</font><br>\n");
    $result = mysql_query("UPDATE girlz SET lastsort='$lastsort',firstsort='$firstsort',middlesort='$middlesort' WHERE ID='$girlID'") or die('Unable to update '.mysql_error());
    $updated++;
    echo("<b>Updated $updated rows</b><br>\n");
} $totalupd += $updated; } echo("<b>Total updated: $totalupd rows</b><br>\n"); mysql_close(); I upgraded to 4.3.0 only to be able to use html_entity_decode(), and because my new host is using 4.3.0, and I try to keep the same version level for proper testing purposes. It only happens on this one script, which only purpose is to transpose some names with HTML entities into something that MySQL can sort properly... the weird thing is: I had the html_entity_decode in a sub-function, and it worked fine. Then I moved it into the main script and removed the function, and it does this error. I've got 2 other much bigger and much more complex scripts that work on the same DB/table with similar, but double queries with and without limits, and they work without any problems at all. What causes this? ... And how the heck do I make it work properly ??? TIA Rene -- Rene Brehmer aka Metalbunny http://metalbunny.net/ References, tools, and other useful stuff...

« previous php.general (#181028) next »