Welcome to WebmasterWorld Guest from 54.163.68.15

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

HTTP 500 Internal Service Error

   
6:58 am on Jun 14, 2009 (gmt 0)

5+ Year Member



Here is the whole copy of my coding, and when I upload and try to open the page, I met the Http 500 error.
Please help me check the code, I don't see any problem myself after so many times of modification and failure...
Thanx


<?php $BoxID=1; //the starting box ID value

//connect to MySQL database
mysql_connect('localhost','****username***','****pw***') or die('cannot connect the database');
mysql_select_db('****dbname****');

//start building the table content
define($table_row,10);//10 rows
define($table_c,5);//and 5 coloums, forms 50 boxes

while ($table_row>0)
{
echo ('<tr>');
while ($table_c>0)
{
//query from the Database for each box.
$query=mysql_query("SELECT * FROM ***tablename*** WHERE ID='$BoxID'");

if($query)//determine if the box contain any content
{
$result=mysql_fetch_array($query);
define($url,$result[7])
define($title,$result[1])
define($text,$result[6])
define($img_url,$result[2])
define($imgh,$result[3])
define($imgw,$result[4])
define($expire,$result[8])

echo ('<td width="160" height="150" valign="top"><p align="center" class="emptybox">UniverseBoard Box #$BoxID<br> <a onClick="href=\'$url\'" style="cursor:hand" title="$text" class="BoxTitle">$title<br>
<img src="$img_url" width="$imgw" height="$imgh"><br>
</a><span class="Expire">Expire: $expire</span></td>')
}//for if function

else //the box contains nothing in database
{
echo('<td width="160" height="150" valign="top"><p align="center" class="emptybox">UniverseBoard Box #$BoxID<br><br><br><p align="center" class="emptybox">This box is AVAILABLE<br /><a href="advertise.php" class="emptybox">Order here</a></td>');
}//else

$BoxID++;
$table_c--;
}//for this row of table
echo ('</tr>');
$table_row--;
}

?>

8:20 am on Jun 14, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two errors I noticed are:

  • ";" missing in many of your lines.
  • I normally use define for constants and var for variables to declare them
  • 9:38 am on Jun 14, 2009 (gmt 0)

    WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



    Start by uploading a file like:

    <html><body>Can you see these words?</body></html>

    and see if you get the same error message.

    The problem might not be your script at all.

    7:25 pm on Jun 14, 2009 (gmt 0)

    5+ Year Member



    Put this at the top of your code also

    error_reporting(E_ALL);
    ini_set("display_errors", 1);

    7:53 pm on Jun 14, 2009 (gmt 0)

    WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



    ... And when you get a 500-Server error, go straight to the server error log and read it -- It often contains very useful information about errors.

    Jim

    4:32 am on Jun 15, 2009 (gmt 0)

    5+ Year Member



    Thank you guys. The problem solved.
    I need to apologize, the cause of the problem is that I DID miss many ";" behind those define statements.
    Then I used direct assignments instead of "define"s, the page displays well by now.