Take the 2-minute tour ×

For example, testing the code:

die ("Hey loser, check your server connection.");
$quey1="select * from student";
$result=mysql_query($quey1) or die(mysql_error());
<table border=1 style="background-color:#F0F8FF;" >
<caption><EM>Student Record</EM></caption>
<th>Student ID</th>
<th>Student Name</th>
echo "</td><td>";
echo $row['stud_id'];
echo "</td><td>";
echo $row['stud_name'];
echo "</td><td>";
echo $row['stud_class'];
echo "</td></tr>";
echo "</table>";

Gives me: PHP Error

I've also experienced the error in that using doesn't work, while hello world";?> in an html page will display 'hello world";?>' on the page. Not sure quite what is wrong...Anyone have a clue?

share|improve this question
The answers point out that you are trying to invoke the script directly. You must access it through a webserver. The latest PHP has a built-in webserver. php.net/manual/en/features.commandline.webserver.php –  Martin Mar 8 '12 at 3:36
Why oh why would the devs put that in? Guess it may be helpful to beginners though. –  Corbin Mar 8 '12 at 3:39
add comment

2 Answers

up vote 6 down vote accepted

You need to access the file through the web server, not directly on your disk.



share|improve this answer
add comment

You can't open a html file directly from your disk and expects your browser to interpret all those php scripts.

You need to actually install a web server like apache with php interpreter and point your browser to the url of your local apache installation docroot.

share|improve this answer
add comment

Your Answer


