I noticed an unusual problem with some of my php programs. Sometimes when you visit a page, for example profile.edit.php, the browser displays a dialog box asking you to load the profile.edit.php page. When I download it, there is nothing in the file. Profile.edit.php is supposed to be a web form that edits user information.
I noticed this on some of my other php pages. I look through the apache error logs and see a segmentation error message:
[Mon Mar 08 15:40:10 2010] [notice] child pid 480 exit signal Segmentation fault (11)
In addition, the problem may or may not appear depending on which server I am also deploying the application on.
Additional Information
This does not happen all the time. Sometimes this happens. For example, profile.edit.php will load properly. But as soon as I click the save button (form action = "profile.edit.php? Save = true"), then the page will ask me to load profile.edit.php. Maybe sometimes my php scripts consume too many resources?
Code example
After saving the action, my profile.edit.php includes the data_access_object.php file. I traced the code in data_access_object.php in this line here
if($params[$this->primaryKey])
{
$q = "UPDATE $this->tableName SET ".implode(', ', $fields)." WHERE ".$this->primaryKey." = ?$this->primaryKey";
$this->bind($this->primaryKey, $params[$this->primaryKey], $this->tblFields[$this->primaryKey]['mysqlitype']);
}
else
{
$q = "INSERT $this->tableName SET ".implode(', ', $fields);
}
if(!$this->execute($q)){ $this->errorSave = -3; return false;}
And if that helps, here's the execute ($ sql) function in data_access_object.php
function execute($sql)
{
$arrListParam = array_bubble_up('arrayName', $this->arrBind);
foreach($arrListParam as $listName)
if($listName)
{
$explodeParam = array();
$arrList = $this->arrBind[$listName]['value'];
foreach($arrList as $key=>$val)
{
$newParamName = $listName.$key;
$this->bind($newParamName,$val,$this->arrBind[$listName]['type']);
$explodeParam[] = '?'.$newParamName;
}
$sql = str_replace("?$listName", implode(',',$explodeParam), $sql);
}
$sqlParsed = preg_replace('/\?[\w\d_\.]+/', '?', $sql);
$this->stmt->prepare($sqlParsed);
preg_match_all('/\?[\w\d_\.]+/', $sql, $matches);
$matches = $matches[0];
$types = ''; $params = array();
foreach($matches as $paramName)
{
$types .= $this->arrBind[str_replace('?', '', $paramName)]['type'];
$params[] = $this->arrBind[str_replace('?', '', $paramName)]['value'];
}
$input = array('types'=>$types) + $params;
if(!empty($types))
call_user_func_array(array($this->stmt, 'bind_param'), $input);
$stat = $this->stmt->execute();
if($GLOBALS['DEBUG_SQL'])
echo '<p style="font-weight:bold;">SQL error after execution:</p> ' . $this->stmt->error.'<p> </p>';
$this->arrBind = array();
return $stat;
}