Can't open ".php" files in browser
| From: | Ken Tozier | Date: | Sun, 13 Apr 2003 17:46:33 +0000 |
| Subject: | Can't open ".php" files in browser | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-10612@lists.php.net to get a copy of this message | ||
I downloaded PHP 4.3.1 onto my Mac OS 10.2.4 machine last night, compiled it etc and there seem to be two problems when running a form script.
The first problem has something to do with the ".php" file extension. I can't open the page in any browser, even though the content of the page was copied directly from the book "MySQL visual quickstart guide". Aren't browsers supposed to handle php? Anyone know what might be causing this problem? Permissions, filebindings?
The second problem happens when I put a link to the "xxx.php" in another page in an effort to try to force the browser to open the page. What happens is that it seems to break on my second call to "$HTTP_POST_VARS" as at the end of this function, everything else in the script paints in the browser as plain text (you can see all script code from the failure point on). I know "$HTTP_POST_VARS" works at least once because it doesn't appear in the browser. Anyone shed some light on this for me?
Here's the offending php:
Thanks,
Ken
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Add an expanse category to the database</title></head> <body> <?php
// handles property insertion into photo database
if (!isset($HTTP_POST_VARS['submit']))
{
// if form has not been submitted
Add a new photo property to the photo table
<form action="add_expense_category.php" method="post">
<input type="text" name="expense_category" size="30" maxlength="30"><p>
<input type="submit" name="submit" value="Submit">
</form>
}
else
{
// if form has been submitted, handle it
// check required for field
if (strlen($HTTP_POST_VARS['expense_category']) > /****** ALL PHP FROM HERE TO SCRIPT END GETS RENDERED IN THE BROWSER***********\ 0)
{
// include mysql information
require_once("../mysql_connect.inc");
// create the query
$query = "INSERT INTO expense_categories VALUES (NULL, '{$HTTP_POST_VERS['expense_category']}')";
// execute the query
$query_result = mysql_query ($query);
// print message indication success or failure
if ($query_result)
{
echo '<b><font color="green">The expense category has been added</font></b>';
}
else
{
echo '<b><font color="red">The expense category has not been added</font></b>';
}
// free up the memory
mysql_close();
}
else
{
// print a message if they failed to enter any text
echo '<b><font color="red">You forgot to enter a new expense category</font></b>';
}
}
?>
</body>
</html>