469,332 Members | 7,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Coding/form problem

Hi.
I am just in the very early stages of learning Php and just need a
little help.

I have a form which includes values. However when I test it, the
values are not added up and carried to the results page. I just
wondered if you can spot whats wrong with it?
This is the form on the page tourprice.php:

<form name="frm_tourprice" id="frm_tourprice" method="post"
action="tourprice_processor.php">
<table width="60%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>Number of Adults </td>
<td><input name="numAdults" type="text" id="numAdults"
/></td>
</tr>
<tr>
<td>Number of Children </td>
<td><input name="numChildren" type="text" id="numChildren"
/></td>
</tr>
<tr>
<td>Tour Name </td>
<td><select name="tourName" id="tourName">
<option value="500">Highlights of Argentina</option>
<option value="700">Highlights of Western Canada</option>
<option value="900">Egyptian Pyramids and More</option>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit"
/></td>
</tr>
</table>
</form>

On the tourprice_calculator.php page it is supposed to add everything
up depending on what you select and give you the correct cost. I keep
getting a zero returned though.

This is at the top of tourprice_calculator.php

<?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)
?>

Further down on the page I have the following:

Tour Price Calculator </h1>
<p>The estimated cost of your tour is <strong><?php echo
$tourPrice; ?></strong>.</p>
<p>Price includes hotel, accommodation, and travel expenses during
the tour. They do not include airfare to the starting destination.</p>
<p><a href="tourprice.php">Calculate</a> another tour.</p>
<p><a href="contact.php">Contact</a> one of our qualified
agents.</p>
Thanks very much for any help. Im a little confused with this one. I
thought it might be some of the strings like $Adult $Adults $Children
$Child etc that were wrong, but when I tried changing those it still
comes up as zero.

John
Jul 17 '05 #1
14 1834
On Wed, 26 May 2004 22:35:47 +0100, John <da***@duck.com> wrote:
On the tourprice_calculator.php page it is supposed to add everything
up depending on what you select and give you the correct cost. I keep
getting a zero returned though.

This is at the top of tourprice_calculator.php

<?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)


Before you do anything else, modify your php.ini and set:

error_reporting = E_ALL

It would have clearly shown what was wrong here.

Notice: Use of undefined constant numAdult - assumed 'numAdult' in
/home/andyh/public_html/test.php on line 5

Notice: Use of undefined constant basePrice - assumed 'basePrice' in
/home/andyh/public_html/test.php on line 5

Notice: Use of undefined constant numChild - assumed 'numChild' in
/home/andyh/public_html/test.php on line 5

Notice: Use of undefined constant basePrice - assumed 'basePrice' in
/home/andyh/public_html/test.php on line 5

Addition and multiplication aren't defined for strings, so you end up with a
zero instead.

You need to put $ in front of variable names.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #2
On Wed, 26 May 2004 23:14:32 +0100, Andy Hassall <an**@andyh.co.uk>
wrote:
On Wed, 26 May 2004 22:35:47 +0100, John <da***@duck.com> wrote:
On the tourprice_calculator.php page it is supposed to add everything
up depending on what you select and give you the correct cost. I keep
getting a zero returned though.

This is at the top of tourprice_calculator.php

<?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)
Before you do anything else, modify your php.ini and set:

error_reporting = E_ALL


I checked the ini file and it seems to already be set.

This is what it says:

error_reporting = E_ALL & ~E_NOTICE

It would have clearly shown what was wrong here.
How do you get it to show all these errors? When I go to validate the
documents in Dreamweaver it doesn't come up with any.
Notice: Use of undefined constant numAdult - assumed 'numAdult' in
/home/andyh/public_html/test.php on line 5

Notice: Use of undefined constant basePrice - assumed 'basePrice' in
/home/andyh/public_html/test.php on line 5

Notice: Use of undefined constant numChild - assumed 'numChild' in
/home/andyh/public_html/test.php on line 5

Notice: Use of undefined constant basePrice - assumed 'basePrice' in
/home/andyh/public_html/test.php on line 5

Addition and multiplication aren't defined for strings, so you end up with a
zero instead.

You need to put $ in front of variable names.


?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)

Do I put the $ within these brackets as well so I have...?

?php
$numAdult = $_POST['$numAdults'];
$numChild = $_POST['$numChildren'];
$basePrice = $_POST['$tourName'];
$tourPrice = ($numAdult * $basePrice) + ($numChild * $basePrice)
And would that need to go on the inital page too within the form?
e.g.

<td>Number of Adults </td>
<td><input name="$numAdults" type="text" id="$numAdults"
/></td>
Thanks

John

Jul 17 '05 #3
Hello.

I'd like to set up MySQL to run locally on my system but I'm having a
little trouble.

The one I have in the phpdev folder on drive C that I got from
firepages doesn't work.

I have downloaded it from the MySQL website, and installed to c:, but
when I goto c:\mysql\bin and click on WinMySqlAdmin it comes up with
an error saying that LIBMYSQL.DLL was not found.

I have tried reinstalling but it makes no difference. If you know
what the problem is I'd be very grateful for your help.

Thanks

John
Jul 17 '05 #4
In article <pk********************************@4ax.com>, he***@hi.com
says...
Hello.

I'd like to set up MySQL to run locally on my system but I'm having a
little trouble.

The one I have in the phpdev folder on drive C that I got from
firepages doesn't work.

I have downloaded it from the MySQL website, and installed to c:, but
when I goto c:\mysql\bin and click on WinMySqlAdmin it comes up with
an error saying that LIBMYSQL.DLL was not found.

I have tried reinstalling but it makes no difference. If you know
what the problem is I'd be very grateful for your help.

Thanks

John


Hmmm... is the my.ini file in your system directory? Because if it's not
it probably is causing the problem. It's what tells MySQL where
everything is.

Jul 17 '05 #5
On Mon, 31 May 2004 03:58:42 GMT, Tony P.
<kd**@nospamplease.verizon.reallynospam.net> wrote:
In article <pk********************************@4ax.com>, he***@hi.com
says...
Hello.

I'd like to set up MySQL to run locally on my system but I'm having a
little trouble.

The one I have in the phpdev folder on drive C that I got from
firepages doesn't work.

I have downloaded it from the MySQL website, and installed to c:, but
when I goto c:\mysql\bin and click on WinMySqlAdmin it comes up with
an error saying that LIBMYSQL.DLL was not found.

I have tried reinstalling but it makes no difference. If you know
what the problem is I'd be very grateful for your help.

Thanks

John


Hmmm... is the my.ini file in your system directory? Because if it's not
it probably is causing the problem. It's what tells MySQL where
everything is.


Hi. No I can't seem to find anything in the system directory.

Which folder in MySql can I find the file to copy? I had a look in
the Bin folder but it seems to be all .exe's in there. Do I just
leave the .DLL file where it is, or does that need copying to system
as well?

Thanks for your help

John

Jul 17 '05 #6
On Sun, 30 May 2004 20:25:28 +0100, John <he***@hi.com> wrote:
On Wed, 26 May 2004 23:14:32 +0100, Andy Hassall <an**@andyh.co.uk>
wrote:
On Wed, 26 May 2004 22:35:47 +0100, John <da***@duck.com> wrote:
On the tourprice_calculator.php page it is supposed to add everything
up depending on what you select and give you the correct cost. I keep
getting a zero returned though.

This is at the top of tourprice_calculator.php

<?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)
Before you do anything else, modify your php.ini and set:

error_reporting = E_ALL


I checked the ini file and it seems to already be set.

This is what it says:

error_reporting = E_ALL & ~E_NOTICE


Which says to hide (because of the ~) all 'notice' level warnings. Change it
to read exactly as I posted above.
It would have clearly shown what was wrong here.


How do you get it to show all these errors? When I go to validate the
documents in Dreamweaver it doesn't come up with any.


No idea about Dreamweaver, I've never used it. I just ran the script from a
browser as normal.
Notice: Use of undefined constant numAdult - assumed 'numAdult' in
/home/andyh/public_html/test.php on line 5 [snip] You need to put $ in front of variable names.


?php
$numAdult = $_POST['numAdults'];
$numChild = $_POST['numChildren'];
$basePrice = $_POST['tourName'];
$tourPrice = (numAdult * basePrice) + (numChild * basePrice)

Do I put the $ within these brackets as well so I have...?

?php
$numAdult = $_POST['$numAdults'];


Don't just pile $ signs in everywhere - put them in front of variables.
$numChild = $_POST['$numChildren'];
$basePrice = $_POST['$tourName'];
$tourPrice = ($numAdult * $basePrice) + ($numChild * $basePrice)
What happened when you tried it?
The $tourPrice line is now correct, but all the others are now wrong.
And would that need to go on the inital page too within the form?
e.g.

<td>Number of Adults </td>
<td><input name="$numAdults" type="text" id="$numAdults"


No.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #7
In article <dj********************************@4ax.com>, he***@hi.com
says...
On Mon, 31 May 2004 03:58:42 GMT, Tony P.
<kd**@nospamplease.verizon.reallynospam.net> wrote:
In article <pk********************************@4ax.com>, he***@hi.com
says...
Hello.

I'd like to set up MySQL to run locally on my system but I'm having a
little trouble.

The one I have in the phpdev folder on drive C that I got from
firepages doesn't work.

I have downloaded it from the MySQL website, and installed to c:, but
when I goto c:\mysql\bin and click on WinMySqlAdmin it comes up with
an error saying that LIBMYSQL.DLL was not found.

I have tried reinstalling but it makes no difference. If you know
what the problem is I'd be very grateful for your help.

Thanks

John


Hmmm... is the my.ini file in your system directory? Because if it's not
it probably is causing the problem. It's what tells MySQL where
everything is.


Hi. No I can't seem to find anything in the system directory.

Which folder in MySql can I find the file to copy? I had a look in
the Bin folder but it seems to be all .exe's in there. Do I just
leave the .DLL file where it is, or does that need copying to system
as well?


In the distribution source there are various example .ini files for
different MySQL setups. I believe you copy one of those as my.ini to the
boot drive's Win folder, be it WINNT or Windows.

It's a really simple file:
[mysqld]
basedir=d:\mysql
datadir=d:\mysql\data

All it does is point to the MySQL base and data directories.

Jul 17 '05 #8
The problem is that I get the following message when I try and run the
winmysqladmin filein the bin folder "This application has failed to
start because LIBMYSQL.dll was not found." I need to get this bit
working first.

John
Jul 17 '05 #9
In article <j2********************************@4ax.com>, he***@hi.com
says...
The problem is that I get the following message when I try and run the
winmysqladmin filein the bin folder "This application has failed to
start because LIBMYSQL.dll was not found." I need to get this bit
working first.

John


It's because you my.ini file doesn't know where the base is.

It's located in drive:\{InstallDir}\Embedded\debug.

I have already posted a sample my.ini file, it's just two lines. One
tells the system where the base directory for MySQL is, the other where
the data is located.

Jul 17 '05 #10
On Mon, 31 May 2004 20:54:16 GMT, Tony P.
<kd**@nospamplease.verizon.reallynospam.net> wrote:
In article <j2********************************@4ax.com>, he***@hi.com
says...
The problem is that I get the following message when I try and run the
winmysqladmin filein the bin folder "This application has failed to
start because LIBMYSQL.dll was not found." I need to get this bit
working first.

John


It's because you my.ini file doesn't know where the base is.

It's located in drive:\{InstallDir}\Embedded\debug.

I have already posted a sample my.ini file, it's just two lines. One
tells the system where the base directory for MySQL is, the other where
the data is located.

I changed the my.ini file located in C:\Windows\system32 to what you
said in the second reply:

[mysqld]
basedir=C:\mysql
datadir=C:\mysql\data

And then I changed it again to what you said in the last reply for
where the dll file is located:

[mysqld]
basedir=C:\mysql\Embedded\DLL\debug
datadir=C:\mysql\data

Neither of these made any difference I still get the same message
saying "This application has failed to start because LIBMYSQL.dll was
not found."

John
Jul 17 '05 #11
In article <av********************************@4ax.com>, he***@hi.com
says...
On Mon, 31 May 2004 20:54:16 GMT, Tony P.
<kd**@nospamplease.verizon.reallynospam.net> wrote:
In article <j2********************************@4ax.com>, he***@hi.com
says...
The problem is that I get the following message when I try and run the
winmysqladmin filein the bin folder "This application has failed to
start because LIBMYSQL.dll was not found." I need to get this bit
working first.

John


It's because you my.ini file doesn't know where the base is.

It's located in drive:\{InstallDir}\Embedded\debug.

I have already posted a sample my.ini file, it's just two lines. One
tells the system where the base directory for MySQL is, the other where
the data is located.

I changed the my.ini file located in C:\Windows\system32 to what you
said in the second reply:

[mysqld]
basedir=C:\mysql
datadir=C:\mysql\data

And then I changed it again to what you said in the last reply for
where the dll file is located:

[mysqld]
basedir=C:\mysql\Embedded\DLL\debug
datadir=C:\mysql\data

Neither of these made any difference I still get the same message
saying "This application has failed to start because LIBMYSQL.dll was
not found."


Ah - I may have confused you when I stated system dir - system dir to me
= win dir. In any case, the original version belongs in c:\windows

You don't have to tell it where the DLL is - it knows based on the
basedir variable.

Jul 17 '05 #12
John <he***@hi.com> wrote in news:av7nb0h6bloakil34q69uc8gsglchcqbki@
4ax.com:
basedir=C:\mysql\Embedded\DLL\debug
datadir=C:\mysql\data


just chiming in here, and I dont know if this is the root problem... but on
windows, all file paths must be in quotes:

so

C:\path should be "C:\path"
Jul 17 '05 #13
In article <Xn*************************@216.168.3.44>,
in*****@noemail.com says...
John <he***@hi.com> wrote in news:av7nb0h6bloakil34q69uc8gsglchcqbki@
4ax.com:
basedir=C:\mysql\Embedded\DLL\debug
datadir=C:\mysql\data


just chiming in here, and I dont know if this is the root problem... but on
windows, all file paths must be in quotes:

so

C:\path should be "C:\path"


No, this is an ini file - no such rules apply.

Jul 17 '05 #14
Tony P. <kd**@nospamplease.verizon.reallynospam.net> wrote in
news:MP************************@news.verizon.net:
No, this is an ini file - no such rules apply.


example cut/paste from php.ini

extension_dir = "C:\php\extensions"

it might depend on the windows version. NT based ones require it. I dunno
about the others.
Jul 17 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Berthold Höllmann | last post: by
8 posts views Thread by worldbadger | last post: by
2 posts views Thread by manning_news | last post: by
144 posts views Thread by Natt Serrasalmus | last post: by
20 posts views Thread by TJ Doherty | last post: by
86 posts views Thread by PTY | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.