[PHP] HELP! Apache dies on regular MySQL query :-/

2004-03-20 Thread -{ Rene Brehmer }-
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, [EMAIL PROTECTED] 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,
  'àáâãäçèéêëìíîïñòóôõöšùúûüýÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕ֊ÙÚÛÜÝ', 
'acnosyACNOSY');
//  $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('bWorking on '.strtoupper(chr($i)).'/bbr');
// 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('bLoaded/working on '.$numrows.' rows/bbr');
  $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=\#ff\$firstname $middlename $lastname/font);
echo(font color=\#80\$firstsort $middlesort 
$lastsort/fontbr\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(bUpdated $updated rows/bbr\n);
  }
  $totalupd += $updated;
}
echo(bTotal updated: $totalupd rows/bbr\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...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] HELP! Apache dies on regular MySQL query :-/

2004-03-20 Thread Raditha Dissanayake

Internal Server Error

The server encountered an internal error or misconfiguration and was 
unable to complete your request.

Please contact the server administrator, [EMAIL PROTECTED] 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.
Apached does not die just because a script misbehave. Please refer to 
the line above.

--
Raditha Dissanayake.
-
http://www.radinks.com/print/upload.php
SFTP, FTP and HTTP File Upload solutions 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php