Re: Can't open ".php" files in browser

From: Date: Sun, 13 Apr 2003 19:13:05 +0000
Subject: Re: Can't open ".php" files in browser
References: 1  Groups: php.install 
Request: Send a blank email to php-install+get-10613@lists.php.net to get a copy of this message
A browser will only open a php file correctly if it is opened with a web server, by putting the file in the directory where your index.html is kept, and accessed by typing in http://127.0.0.1/phpfile.php (which looks at the directory where your index.html is). I have recently discovered that some of the global variables work differently than they used to on any PHP version that is newer than 4.1. In fact, I went and bought a new book yesterday that writes code in the presently accepted new format, because I kept finding the code needed to be changed. I could never get a script with $HTTP_POST_VARS to work with the newer PHP revision. I hope this helps, David Ken Tozier wrote: > 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> > > -- > PHP Install Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.install (#10613) next »