簡體   English   中英

Drupal中的HTTP錯誤500(內部服務器錯誤)

[英]HTTP Error 500 (Internal Server Error) in Drupal

Iam使用JSON將數據提供給使用php的ios應用程序。 但是在瀏覽器中運行代碼時,它顯示服務器錯誤。 如果數據庫中沒有值,它將顯示代碼中提供的{"posts":null} 但是,如果數據庫中有值,則會出現問題。 顯示錯誤

Server error The website encountered an error while retrieving http://path to the server file/php/categoryitemlisting.php?category=11. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. 僅針對此php文件會發生此錯誤。 使用其他文件,我可以傳輸數據。

我的connection.php文件:

<?php
$link = mysql_connect("127.0.0.1","root","") or die('Cannot connect to the DB');
mysql_set_charset("utf8");
mysql_select_db('cotton',$link) or die('Cannot select the DB');
?>

Categoryitemlisting.php

 <?php

   require('connection.php');
   $item = array()       ;

   /* connect to the db */
      if(isset($_REQUEST['category']))
      {
            $k=$_REQUEST['category'];
        /* grab the posts from the db */
             // $k=11;
            $catid = mysql_query("SELECT entity_id FROM  field_data_field_cat WHERE field_cat_tid= $k");
            while($r = mysql_fetch_assoc($catid))
           {

               $category[] = $r['entity_id'];   
               foreach ( $category as $cat );
              {

                 $data= mysql_query("SELECT field_data_field_name.entity_id, field_data_field_name.field_name_value, file_managed.uri, field_data_field_sec.field_sec_tid FROM file_managed INNER JOIN ( field_data_field_thumb, field_data_field_name, field_data_field_sec ) ON ( file_managed.fid = field_data_field_thumb.field_thumb_fid AND field_data_field_name.entity_id = field_data_field_thumb.entity_id AND field_data_field_thumb.entity_id = field_data_field_sec.entity_id ) WHERE field_data_field_name.entity_id = $cat");  

               $items = mysql_fetch_assoc($data);
               $item[]= $items;
              }
            }
                $re="public:\/\/";
                $list = json_encode(array('posts'=>$item));
            $list = str_replace( $re, "http://localhost/sites/default/files/" ,$list);
                echo $list;

             @mysql_close($link);

      }

      else
      {
      echo "connection failed";
      }
?>

如何通過修復此錯誤獲取值? 我不認為這是服務器的問題。 代碼中是否還有其他錯誤?

查看您的php.ini並設置:

display_errors = on
error_reporting = E_ALL

如果display_error關閉,並且您的代碼有任何類型的問題(例如:解析錯誤),您的響應將是500狀態頁面。

最后指出了這個問題。

$k=$_REQUEST[' category'];有一個空格$k=$_REQUEST[' category']; 在服務器代碼中。 那導致了錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM