PHP komut dosyası daha sonra tarayıcı içinde hiçbir şey. Php dosyasını indirmek için bana sorar segment hataya neden olur?

5 Cevap php

Benim php programlar bazı alışılmadık bir sorun fark ettik. Profile.edit.php gibi bir sayfasını ziyaret Bazen, tarayıcı profile.edit.php sayfasını indirmek isteyen bir diyalog kutusu atar. Bunu indirdiğinizde, dosyada hiçbir şey yok. profile.edit.php kullanıcı bilgilerini düzenler bir web formu olması gerekiyordu.

Ben benim diğer php sayfaları bazıları da bu fark ettik. Benim apache hata günlüklerine bakmak, ve ben bir segmentasyon hata mesajı görürsünüz:

[Mon Mar 08 15:40:10 2010] [notice] child pid 480 exit signal Segmentation fault (11)

Ve aynı zamanda, konu ya da ben de benim uygulamayı dağıtmak hangi sunucunun bağlı olarak görünmeyebilir.

Additonal Details This doesn't happen all the time though. It only happens sometimes. For example, profile.edit.php will load properly. But as soon as I hit the save button (form action="profile.edit.php?save=true"), then the page asks me to download profile.edit.php. Could it be that sometimes my php scripts consume too much resources?

Sample code

Eylem kaydetmek üzerine, benim profile.edit.php bir data_access_object.php dosyası içerir. Ben burada bu hat için data_access_object.php kodu takip

 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);
}
// Code executes perfectly up to this point
// echo 'print this'; exit; // if i uncomment this line, profile.edit.php will actually show 'print this'.  If I leave it commented, the browser will ask me to download profile.edit.php
if(!$this->execute($q)){ $this->errorSave = -3; return false;}
// When I jumped into the function execute(), every line executed as expected, right up to the return statement.  

Eğer yardımcı olur ve burada işlev data_access_object.php içinde ($ sql) yürütmek bulunuyor

function execute($sql)
{

        // find all list types and explode them
        // eg. turn ?listId into ?listId0,?listId1,?listId2 
        $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);
           }

        // replace all ?varName with ? for syntax compliance
        $sqlParsed = preg_replace('/\?[\w\d_\.]+/', '?', $sql);
        $this->stmt->prepare($sqlParsed);

        // grab all the parameters from the sql to create bind conditions
        preg_match_all('/\?[\w\d_\.]+/', $sql, $matches);
        $matches = $matches[0];

        // store bind conditions
        $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;



        // bind it
        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>&nbsp;</p>';

        $this->arrBind = array();
        return $stat;
}

5 Cevap

Bu da büyük ihtimalle yanlış sunucu yapılandırması tarafından neden olur. Sunucu, bir PHP programı olarak yorumlamak değil, doğrudan dosya gönderiyor. Apache kullanıyorsanız bu yana, aşağıdaki yapılandırma ayarı (from here) sorunu düzeltmek gerekir:

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

Edit: daha derin bir sorun var gibi görünüyor. Bu yanıt altında ve özgün soru üzerine yorum bakın.

Bu genellikle PHP yüklü veya sunucusunda doğru yapılandırılmamış yok demektir.

Üretilen son SQL ifadesi neye benziyor? Eğer var burada:

// echo 'print this'; exit; 

Buna ne değişti eğer:

echo "Query: $q";
exit;

Ve söz sonuçlarını açıkladı ...

Ne söyleyebilirim itibaren, sorgu gibi görünecektir:

INSERT some_table SET field1, field2, field3

Olması gerekir:

INSERT INTO some_table SET field1='value 1', field2='value 2', field3='value 3'

I think it should be AddType application/x-httpd-php .php .phtml in the httpd.conf

I'm saving my answer because it's a fix but his real problem is the use of "action" in the HTML form. The form should be:

<form action="myphpfile.php" method="get">
  <input type="hidden" name="save" value="true" />
  First name: <input type="text" name="firstname" /><br />
  Last name: <input type="text" name="lastname" /><br />
  <input type="submit" value="Submit" />
</form>

Eğer gizli bir girişi yerleştirmek formu eylem bir sorgu kullanmayın. Ben hataları seg neden olduğunu düşünüyorum. Verileri kaydetmek için gidiyoruz eğer ben size "yazı" kullanmanız gereken yöntemi olarak "get" kullanmak olmaz. Ben aslında her zaman "yazı" kullanın.

Için Apache request timeout hem php execution timeout ve komut dosyasını çalıştırmak için gerekli süreden daha az ise bu olabilir.

Apache aşımı ulaşıldığında, apache bağlantısını kapatmak için görünür. Tarayıcı temiz kapalı bağlantıyı görüyor ama herhangi bir içerik yoktur ve bu yüzden çok dosyayı kaydetmek isteyip istemediğinizi sorarak geri tanınmayan içerik için varsayılan davranış düşer, onunla ne yapacağını tanımak mümkün de değildir.

Echo deyimi, 'Bu baskı' uncommenting ve çıkışlar tarayıcınızın bazı metin çıkarken yerine uzun süren sürecine girmeden. Apache aşımı ulaşmış değil ve tarayıcı bunun varsayılan olarak göstermek gerektiğini bilir content gelmiştir.

Script sadece bazen apache zaman aşımı aşan, işlem süresi değişir eğer arada olay açıklanabilir. Ya da belki script yerde engelliyor.

Komut dosyası zaman aşımı her zaman apache zaman aşımı daha düşük ise, daha bilgilendirici 'Ölümcül hata: Maksimum yürütme zamanı ...' getireyim hatası yerine.