HTTP 500 (Internal Server Error) เว็บ Error 500 แก้ไขดี

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderators: mindphp, ผู้ดูแลกระดาน

postpept
PHP Newbie
PHP Newbie
Posts: 5
Joined: 13/12/2011 11:25 am

HTTP 500 (Internal Server Error) เว็บ Error 500 แก้ไขดี

Post by postpept »

HTTP 500 (Internal Server Error) เว็บ Error 500 แก้ไขดี

ไม่รู้ว่าติดตรงไหนครับ
ถ้ารันบน pc ที่จำลองเป็น server แสดงผลได้
แต่พอเอาไปวางบน server จริง page ที่โชว์ขึ้นมาเป็น
ข้อผิดพลาดของ HTTP 500 (Internal Server Error): เกิดปัญหาที่ไม่คาดคิดในขณะที่เซิร์ฟเวอร์พยายามดำเนินการตามคำขอ

postpept
PHP Newbie
PHP Newbie
Posts: 5
Joined: 13/12/2011 11:25 am

Re: HTTP 500 (Internal Server Error)

Post by postpept »

Code: Select all

<body>

<?php
         $idcontract = $_GET['selcontract'];

         include "connect.php";
         $conn->open($msaccdb);
         $str2 = "SELECT * FROM tb_Equipment
               WHERE ID_Contract = $idcontract";
         $Rec->Open($str2, $conn, 1, 3);
         $maxloop = $Rec->RecordCount();
         while (!$Rec->EOF)
            {   
             $budget[] = $Rec->Fields['Budget_Price']->Value;
             $act[] = $Rec->Fields['Act_Price']->Value;
             $Rec->MoveNext();

            }
         $Rec->Close();
         ?>
<?php
         $idcontract = $_GET['selcontract'];
         include "connect.php";
         $conn->open($msaccdb);
         $str1 = "SELECT tb_Equipment_Type.*, tb_Equipment.*
               FROM tb_Equipment, tb_Equipment_Type
               WHERE tb_Equipment_Type.ID_Equipment_Type = tb_Equipment.ID_Equipment_Type
               AND tb_Equipment.ID_Contract = $idcontract";
         $Rec->Open($str1, $conn, 1, 3);
         $maxloop = $Rec->RecordCount();
         while (!$Rec->EOF)
            {    $ID_Equipment[] = $Rec->Fields['ID_Equipment']->Value;
             $Equipment_Type[] = $Rec->Fields['Equipment_Type']->Value;
             $Rec->MoveNext();
            }
         $Rec->Close();
         
?>


  <center>
    <h1>สรุปข้อมูลการเช่า</h1>
  </center>
  <form action="testreport.php" method="post" name="form_search_ci" id="form_search_ci"></form>
  <table align="center" class="display reporttable" id="cost_table" name="cost_table" border="1">
  <thead>
      <tr>
        <th rowspan="3" class="ui-state-default">CenterNo.</th>
        <th rowspan="3" class="ui-state-default">Function Code</th>
        <th colspan="<? echo $maxloop; ?>" class="ui-state-default">DeviceType</th>
        <th rowspan="3" class="ui-state-default">ค่าเช่าต่อเดือน</th>
        <th rowspan="3" class="ui-state-default">ค่าเช่าต่อปี</th>
        <th rowspan="3" class="ui-state-default">ค่าเช่าต่อ3ปี</th>
      </tr>
      <tr>
      <?php for($i=0;$i<$maxloop;$i++)
        {
        ?>
      <th class='ui-state-default'><? echo $Equipment_Type[$i]; ?></th> <?php } ?>
      </tr>
      <tr>
      <?php for($i=0;$i<$maxloop;$i++)
        {
         if($act[$i] == 0){
            $price = $budget;
            }
         else{
            $price = $act;
            }

        ?>
         <th class="ui-state-default"><? echo $price[$i];?></th> <?php } ?>
      </tr>
      </thead>
    <tbody>
    <?php
         $idcontract = $_GET['selcontract'];
         include "connect.php";
         $conn->open($msaccdb);
         $str1 = "SELECT tb_Equipment.*, tb_Purchase.* ,tb_Function.* , tb_Center_Function.* , tb_Center.*
               FROM tb_Equipment, tb_Purchase , tb_Function , tb_Center_Function , tb_Center
               WHERE tb_Equipment.ID_Equipment = tb_Purchase.ID_Equipment
               AND tb_Equipment.ID_Contract = $idcontract
               AND tb_Function.ID_Function = tb_Purchase.ID_Function
               AND tb_Center_Function.ID_Function = tb_Function.ID_Function
               AND tb_Center_Function.ID_Center = tb_Center.ID_Center
               ORDER BY tb_Center.CenterNo ASC";
         $Rec->Open($str1, $conn, 1, 3);
         $maxlooprent = $Rec->RecordCount();
         while (!$Rec->EOF)
            {    $ID_Equipments = $Rec->Fields['ID_Equipment']->Value;   
             $FunctionCode = $Rec->Fields['Function_Name']->Value;
             $budgetnew = $Rec->Fields['Budget_New']->Value;
             $budgetre = $Rec->Fields['Budget_Replace']->Value;
             $budgetrecon = $Rec->Fields['Budget_Replace_Contract']->Value;
             $actnew = $Rec->Fields['Act_New']->Value;
             $actre = $Rec->Fields['Act_Replace']->Value;
             $actrecon = $Rec->Fields['Act_Replace_Contract']->Value;
             $CenterNo = $Rec->Fields['CenterNo']->Value;
?>      


      <tr >
        <td><? echo $CenterNo; ?></td>
        <td><? echo $FunctionCode; ?></td>
      <? 
      $TotalDivice[] = 0;
      $TotalMonth[] = 0;
      $TotalYear[] = 0;
      $Total3Year[] = 0;
      for($i=0;$i<$maxloop;$i++){ ?>
        <td align="center"><? if($ID_Equipment[$i]== $ID_Equipments){
         $purches = $actnew+$actre+$actrecon;
         if($actnew+$actre+$actrecon == 0){ $purches = $budgetnew+$budgetre+$budgetrecon; }
         echo $purches;
         $TotalDivice[$i] = $purches + $TotalDivice[$i];
         } ?></td>
      <? } ?>
        <td align="right"><?  for($i=0;$i<$maxloop;$i++){
         if($ID_Equipment[$i]== $ID_Equipments){
            $RentMonth = $purches*$price[$i];}
      }      
            echo number_format($RentMonth);
            $TotalMonth[$i] = $RentMonth + $TotalMonth[$i]; ?></td>
        <td align="right"><?  $RentYear = $RentMonth*12;
            echo number_format($RentYear);
            $TotalYear[$i] = $RentYear + $TotalYear[$i];?></td>
        <td align="right"><?  $Rent3Year = $RentYear*3;
            echo number_format($Rent3Year);
            $Total3Year[$i] = $Rent3Year + $Total3Year[$i];?></td>
      </tr>
<?                 $Rec->MoveNext();
            }
      $Rec->Close();
?>

</tbody>
<tfoot>
<tr>
<td colspan="2" align="center"></td>
<? for($i=0;$i<$maxloop;$i++){ ?>
<td align="center" bgcolor="#FFFF00"> <? echo number_format($TotalDivice[$i]); ?> </td>
<? } ?>
<td align="right" bgcolor="#FFFF00">  <? echo number_format($TotalMonth[$i]); ?> </td>
<td align="right" bgcolor="#FFFF00"> <? echo number_format($TotalYear[$i]); ?> </td>
<td align="right" bgcolor="#FFFF00"> <? echo number_format($Total3Year[$i]); ?> </td>
</tr>
</tfoot>
</table>


</body>
</html>
Last edited by postpept on 13/12/2011 1:03 pm, edited 1 time in total.

User avatar
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
Posts: 24728
Joined: 22/09/2008 6:18 pm
Contact:

Re: HTTP 500 (Internal Server Error)

Post by mindphp »

ลงโค้ดช่วยครอบโค้ดหน่อยครับ

Code: Select all

[code=php] โค้ดของท่าน
[/code]
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042

postpept
PHP Newbie
PHP Newbie
Posts: 5
Joined: 13/12/2011 11:25 am

Re: HTTP 500 (Internal Server Error)

Post by postpept »

mindphp wrote:ลงโค้ดช่วยครอบโค้ดหน่อยครับ

Code: Select all

[code=php] โค้ดของท่าน
[/code]
แบบนี้ใช่มั๊ยครับ

Code: Select all

<body>

<?php
			$idcontract = $_GET['selcontract'];

			include "connect.php";
			$conn->open($msaccdb);
			$str2 = "SELECT * FROM tb_Equipment 
					WHERE ID_Contract = $idcontract";
			$Rec->Open($str2, $conn, 1, 3);
			$maxloop = $Rec->RecordCount();
			while (!$Rec->EOF)
	         {	 
				 $budget[] = $Rec->Fields['Budget_Price']->Value;
				 $act[] = $Rec->Fields['Act_Price']->Value;
				 $Rec->MoveNext();

	         }
			$Rec->Close();
			?>
<?php
			$idcontract = $_GET['selcontract'];
			include "connect.php";
			$conn->open($msaccdb);
			$str1 = "SELECT tb_Equipment_Type.*, tb_Equipment.* 
					FROM tb_Equipment, tb_Equipment_Type 
					WHERE tb_Equipment_Type.ID_Equipment_Type = tb_Equipment.ID_Equipment_Type 
					AND tb_Equipment.ID_Contract = $idcontract";
			$Rec->Open($str1, $conn, 1, 3);
			$maxloop = $Rec->RecordCount();
			while (!$Rec->EOF)
	         {	 $ID_Equipment[] = $Rec->Fields['ID_Equipment']->Value;
				 $Equipment_Type[] = $Rec->Fields['Equipment_Type']->Value;
				 $Rec->MoveNext();
	         }
			$Rec->Close();
			
?>


  <center>
    <h1>สรุปข้อมูลการเช่า</h1>
  </center>
  <form action="testreport.php" method="post" name="form_search_ci" id="form_search_ci"></form>
  <table align="center" class="display reporttable" id="cost_table" name="cost_table" border="1">
  <thead>
      <tr>
        <th rowspan="3" class="ui-state-default">CenterNo.</th>
        <th rowspan="3" class="ui-state-default">Function Code</th>
        <th colspan="<? echo $maxloop; ?>" class="ui-state-default">DeviceType</th>
        <th rowspan="3" class="ui-state-default">ค่าเช่าต่อเดือน</th>
        <th rowspan="3" class="ui-state-default">ค่าเช่าต่อปี</th>
        <th rowspan="3" class="ui-state-default">ค่าเช่าต่อ3ปี</th>
      </tr>
      <tr>
      <?php for($i=0;$i<$maxloop;$i++)
	  	{
		  ?>
		<th class='ui-state-default'><? echo $Equipment_Type[$i]; ?></th> <?php } ?>
      </tr>
      <tr>
      <?php for($i=0;$i<$maxloop;$i++)
	  	{ 
			if($act[$i] == 0){
				$price = $budget;
				}
			else{
				$price = $act;
				}

		  ?>
      	<th class="ui-state-default"><? echo $price[$i];?></th> <?php } ?>
      </tr>
      </thead>
    <tbody>
    <?php
			$idcontract = $_GET['selcontract'];
			include "connect.php";
			$conn->open($msaccdb);
			$str1 = "SELECT tb_Equipment.*, tb_Purchase.* ,tb_Function.* , tb_Center_Function.* , tb_Center.*
					FROM tb_Equipment, tb_Purchase , tb_Function , tb_Center_Function , tb_Center
					WHERE tb_Equipment.ID_Equipment = tb_Purchase.ID_Equipment 
					AND tb_Equipment.ID_Contract = $idcontract
					AND tb_Function.ID_Function = tb_Purchase.ID_Function
					AND tb_Center_Function.ID_Function = tb_Function.ID_Function
					AND tb_Center_Function.ID_Center = tb_Center.ID_Center
					ORDER BY tb_Center.CenterNo ASC";
			$Rec->Open($str1, $conn, 1, 3);
			$maxlooprent = $Rec->RecordCount();
			while (!$Rec->EOF)
	         {	 $ID_Equipments = $Rec->Fields['ID_Equipment']->Value;	
				 $FunctionCode = $Rec->Fields['Function_Name']->Value;
				 $budgetnew = $Rec->Fields['Budget_New']->Value;
				 $budgetre = $Rec->Fields['Budget_Replace']->Value;
				 $budgetrecon = $Rec->Fields['Budget_Replace_Contract']->Value;
				 $actnew = $Rec->Fields['Act_New']->Value;
				 $actre = $Rec->Fields['Act_Replace']->Value;
				 $actrecon = $Rec->Fields['Act_Replace_Contract']->Value;
				 $CenterNo = $Rec->Fields['CenterNo']->Value;
?>		


      <tr >
        <td><? echo $CenterNo; ?></td>
        <td><? echo $FunctionCode; ?></td>
		<?  
		$TotalDivice[] = 0;
		$TotalMonth[] = 0;
		$TotalYear[] = 0;
		$Total3Year[] = 0;
		for($i=0;$i<$maxloop;$i++){ ?>
        <td align="center"><? if($ID_Equipment[$i]== $ID_Equipments){
			$purches = $actnew+$actre+$actrecon;
			if($actnew+$actre+$actrecon == 0){ $purches = $budgetnew+$budgetre+$budgetrecon; }
			echo $purches;
			$TotalDivice[$i] = $purches + $TotalDivice[$i];
			} ?></td>
		<? } ?>
        <td align="right"><?  for($i=0;$i<$maxloop;$i++){
			if($ID_Equipment[$i]== $ID_Equipments){
				$RentMonth = $purches*$price[$i];}
		}		
				echo number_format($RentMonth);
				$TotalMonth[$i] = $RentMonth + $TotalMonth[$i]; ?></td>
        <td align="right"><?  $RentYear = $RentMonth*12;
				echo number_format($RentYear); 
				$TotalYear[$i] = $RentYear + $TotalYear[$i];?></td>
        <td align="right"><?  $Rent3Year = $RentYear*3;
				echo number_format($Rent3Year); 
				$Total3Year[$i] = $Rent3Year + $Total3Year[$i];?></td>
      </tr>
<?    				 $Rec->MoveNext();
	         }
		$Rec->Close();
?>

</tbody>
<tfoot>
<tr>
<td colspan="2" align="center"></td>
<? for($i=0;$i<$maxloop;$i++){ ?>
<td align="center" bgcolor="#FFFF00"> <? echo number_format($TotalDivice[$i]); ?> </td>
<? } ?>
<td align="right" bgcolor="#FFFF00">  <? echo number_format($TotalMonth[$i]); ?> </td>
<td align="right" bgcolor="#FFFF00"> <? echo number_format($TotalYear[$i]); ?> </td>
<td align="right" bgcolor="#FFFF00"> <? echo number_format($Total3Year[$i]); ?> </td>
</tr>
</tfoot>
</table>


</body>
</html>

User avatar
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
Posts: 24728
Joined: 22/09/2008 6:18 pm
Contact:

Re: HTTP 500 (Internal Server Error)

Post by mindphp »

จากโค้ด มี

Code: Select all

include "connect.php"; 
สองครั้ง
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042

postpept
PHP Newbie
PHP Newbie
Posts: 5
Joined: 13/12/2011 11:25 am

Re: HTTP 500 (Internal Server Error)

Post by postpept »

mindphp wrote:จากโค้ด มี

Code: Select all

include "connect.php"; 
สองครั้ง
ผมลองเอาออกให้เหลือ 1 ครั้ง ก็ยังขึ้น HTTP 500 (Internal Server Error) เหมือนเดิมครับ

touleg
PHP Super Member
PHP Super Member
Posts: 480
Joined: 25/01/2010 11:57 pm
Contact:

Re: HTTP 500 (Internal Server Error)

Post by touleg »

ลองคอมเม้นโค้ดออกแล้วเรียกดูว่ามันใช้ได้ป่าว

postpept
PHP Newbie
PHP Newbie
Posts: 5
Joined: 13/12/2011 11:25 am

Re: HTTP 500 (Internal Server Error)

Post by postpept »

touleg wrote:ลองคอมเม้นโค้ดออกแล้วเรียกดูว่ามันใช้ได้ป่าว
เหมือนเดิมครับ :cry:

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Programming - PHP”

Who is online

Users browsing this forum: Alexa [Bot] and 7 guests