Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 27th, 2003, 07:15 PM
Authorized User
 
Join Date: Oct 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could it be something in my php.ini setting?


 
Old October 27th, 2003, 07:18 PM
Authorized User
 
Join Date: Oct 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just so you know, I am running Apache2.

I just tried using IE6 on the page and the first page is fine, the php page is blank. I also tried Opera and still nothing.

It has to be in the ini or apache or something else.

 
Old October 27th, 2003, 07:30 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

OK a test of <br/> on Moz 1.5 executed as expected... so that is irrelvant.
In NS 3 the output caused the browser to simply ignore the <br/> tag all-together. HTML tags alone will never caues a page to not display.

So something must be awry with your PHP installation.

What do you see when you run this script.

<?php phpinfo(); ?>

You should see a long, detailed output of configuration settings.

: )
Rich



:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old October 27th, 2003, 07:40 PM
Authorized User
 
Join Date: Oct 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The phpinfo() page is there.

php.ini path: C:\Program Files\Apache Group\Apache2\php.ini


 
Old October 27th, 2003, 08:18 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

That's curious.
I really don't know what more to suggest. Perhaps try the script on a different server to see if the same thing happens. Then it could be tracked down to something apache-specific. If the same behavior does happen then it might be something php-specific.

Try Xitami:
http://www.xitami.com

Its pretty easy to set-up just download the installer and once installed go into the admin panel Configuration->Filters and type in the extenstions you want PHP to parse as well as the path to the php executable e.g. G:\PHP\php.exe.

Temporarily shutdown Apache while you test on Xitami.

If the script can be run on a different server then we can narrow it down to something in Apache.

This is not likely a php problem if you can see phpinfo() output.

Other than that I am not sure what to suggest. Maybe someone else on the list has some ideas.

: )
Rich



:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
 
Old October 28th, 2003, 12:14 PM
Authorized User
 
Join Date: Oct 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok. Tried that server you mentioned but had more trouble with it than I really wanted.

Went back to my apache error logs (which I never thought to check) and found

[client 127.0.0.1] PHP Parse error: parse error, unexpected T_STRING in C:\Documents and Settings\Administrator\My Documents\My Work\PHP\Beg_PHP4\CH3\loan.php on line 1, referer: http://localhost/PHP/Beg_PHP4/CH3/loan.htm

So, I go back to my page and look at line 1.

<?xml version='1.0'?><!doctype html public '-//w3c//dtd xhtml 1.0 strict//en' 'http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml'>
<head><title> Smart Loan Application</title></head>

Now, my question is this: is line 1, line 1 on the page or line 1 of the php script?


 
Old October 28th, 2003, 12:42 PM
Authorized User
 
Join Date: Oct 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok. I took out the doc reference at the top and I found actual problems.

I receive this in my error logs:
[client 127.0.0.1] PHP Notice: Undefined variable: _post in C:\Documents and Settings\Administrator\My Documents\My Work\PHP\Beg_PHP4\CH3\loan.php on line 8, referer: http://localhost/PHP/Beg_PHP4/CH3/loan.htm
[client 127.0.0.1] PHP Notice: Undefined variable: _post in C:\Documents and Settings\Administrator\My Documents\My Work\PHP\Beg_PHP4\CH3\loan.php on line 9, referer: http://localhost/PHP/Beg_PHP4/CH3/loan.htm
[client 127.0.0.1] PHP Notice: Undefined variable: _post in C:\Documents and Settings\Administrator\My Documents\My Work\PHP\Beg_PHP4\CH3\loan.php on line 10, referer: http://localhost/PHP/Beg_PHP4/CH3/loan.htm
[client 127.0.0.1] PHP Notice: Undefined variable: _post in C:\Documents and Settings\Administrator\My Documents\My Work\PHP\Beg_PHP4\CH3\loan.php on line 11, referer: http://localhost/PHP/Beg_PHP4/CH3/loan.htm
[client 127.0.0.1] PHP Notice: Undefined variable: _post in C:\Documents and Settings\Administrator\My Documents\My Work\PHP\Beg_PHP4\CH3\loan.php on line 12, referer: http://localhost/PHP/Beg_PHP4/CH3/loan.htm

Errors on line 8 through 12.

Here is the code for that page:

<head><title> Smart Loan Application</title></head>

<body>

<h1>Smart Credit Bank Loan Application Form</h1>

<?php
    $firstname = $_post['firstname'];
    $lastname = $_post['lastname'];
    $salary = $_post['salary'];
    $age = $_post['age'];
    $loan = $_post['loan'];

    $SalaryAllowance = $salary / 5;
    $AgeAllowance = ($age / 10 - ($age % 10) / 10 ) -1;
    $LoanAllowance = $SalaryAllowance + $AgeAllowance;

    echo 'Loan desired: $loan <br />';
    echo 'Loan amount we will allow: $LoanAllownace <br /><br />';
        if ($loan <= $LoanAllowance) echo 'Yes, $firstname $lastname, we are delighted to accept your application';
        if ($loan > $LoanAllowance) echo 'We\'re sorry, $firstname $lastname, we cannot accept your application at this time.';
?>


<p>Created on ... October 27, 2003</p>
</body>
</html>

The errors in question are the $firstname = $_post['firstname'];

Is there something wrong with that?

 
Old October 28th, 2003, 02:31 PM
Authorized User
 
Join Date: Oct 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok. After some serious head banging against the wall, this is what I have that IS working:

<head><title> Smart Loan Application</title></head>
<body>
<h1>Smart Credit Bank Loan Application Form</h1>

<?php
$SalaryAllowance = $_POST["salary"] / 5;
$AgeAllowance = ($_POST["age"] / 10 - ($_POST["age"] % 10) / 10 ) -1;
$LoanAllowance = $SalaryAllowance + $AgeAllowance;

echo "Loan desired: $_POST[loan] <br /> " ;
echo "Loan amount we will allow: $LoanAllowance <br /><br />";

if ($_POST["loan"] <= $LoanAllowance) echo "Yes, $_POST[firstname] $_POST[lastname], we are delighted to accept your application. ";

if ($_POST["loan"] > $LoanAllowance) echo "We\"re sorry, $_POST[firstname] $_POST[lastname], we cannot accept your application at this time.";
?>

</body>
</html>

I guess I did not understand outside the echo " " you have to have $_POST[" xx "]; and inside you have $_POST[xx];

I also found, for whatever reason, that if I have anything other than POST in caps, it wont work.

Moving along the chapter slowly.

 
Old October 28th, 2003, 02:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, that all makes sense. If you read the PHP manual page for strings and variable substitution, you'll see how variables are parsed within double-quoted and heredoc strings:
  http://www.php.net/types.string

You'll also notice that the superglobal variable names are $_POST, $_GET, etc... not $_post or $_get.
  http://www.php.net/reserved.variables


I think the reason you were having parse errors in your original script is that your php.ini says that "<?" is a valid PHP start tag, so <?xml might screw PHP up. I'd recommend entering PHP and echoing your <?xml line from within PHP:

<?php
echo "<?xml ...";

...


Take care,

Nik
http://www.bigaction.org/
 
Old October 28th, 2003, 03:18 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Yeah all variable names are case sensitive, function names are not.

Quote:
quote:
I guess I did not understand outside the echo " " you have to have $_POST[" xx "]; and inside you have $_POST[xx];
You can also use curly syntax:
if ($_POST["loan"] <= $LoanAllowance)
    echo "Yes, {$_POST["firstname"]} {$_POST["lastname"]}, we are delighted to accept your application.";

http://www.php.net/manual/en/language.types.array.php

In your development environment it would, IMO, be more helpful to output your errors directly to the browser, rather than having to check a log. Those are all directives in PHP.ini.

: )
Rich



:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Fatal Error Chap 3, Pg 96-96 joshkosmala BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 January 8th, 2007 01:55 PM
Changing textboxes to hidden fields - HELP!!! jroxit ASP.NET 1.0 and 1.1 Basics 4 February 10th, 2006 07:46 PM
hidden input fields and Mozilla panos CSS Cascading Style Sheets 1 February 3rd, 2006 05:45 PM
Creating hidden fields SmoothAl BOOK: Beginning ASP 3.0 0 February 6th, 2005 01:44 AM
CH 3 pg 96 Question mririe BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 8 August 25th, 2004 04:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.