473,395 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 2034
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Berthold Höllmann | last post by:
I have a default coding header # -*- coding: iso-8859-15 -*- in my python files. I now have Problems with this settings. I swithched to Python 2.4.1 under Windows. When I import files with the...
8
by: worldbadger | last post by:
Hello there, I have a subform that has anywhere from 20-500 ID numbers (unique) listed on it. Each ID is going to be linked to a picture. First off I set up a check for existance of the file;...
2
by: manning_news | last post by:
Has anyone had a problem with Access 2003 not saving their coding? I've been using 2003 for a couple of months now and just this week noticed that some coding I'd done for a database was not there...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
20
by: TJ Doherty | last post by:
Need help understanding the following please: When I am creating a project and code my connection using Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data...
86
by: PTY | last post by:
Which is better? lst = while lst: lst.pop() OR while len(lst) 0:
0
by: agrenter | last post by:
hi group, I am using a continuous form and filters to make a user-friendly search form. But the filter is being applied, and I'm also getting a parameter box that pops up- so the filter isn't...
0
by: pat | last post by:
CodeCheck Coding Standard's Support As a free service to our customers we offer support in developing "rule-files" for automating corporate coding standards. If you have a coding standard that...
3
by: Tony K | last post by:
I'm note sure how to state this but, I have a Windows form that contains 2 tables. Details View on top and Datagrid on the bottom. The two tables are related. One of the fields in the details...
1
by: higgy2005 | last post by:
Hi there, I would be very greatful if somebody could help me with my trouble using VBA to code a button on a form. Basically what i want to happen is on the click of the button i want it to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.