473,662 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_tourp rice" id="frm_tourpri ce" method="post"
action="tourpri ce_processor.ph p">
<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="numChildr en" type="text" id="numChildren "
/></td>
</tr>
<tr>
<td>Tour Name </td>
<td><select name="tourName" id="tourName">
<option value="500">Hig hlights of Argentina</option>
<option value="700">Hig hlights of Western Canada</option>
<option value="900">Egy ptian 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_calcu lator.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_calcu lator.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.p hp">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 2059
On Wed, 26 May 2004 22:35:47 +0100, John <da***@duck.com > wrote:
On the tourprice_calcu lator.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_calcu lator.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_calcu lator.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_calcu lator.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="$numAdult s" 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**@nospample ase.verizon.rea llynospam.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_calcu lator.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_calcu lator.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_reportin g = 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="$numAdult s" 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**@nospample ase.verizon.rea llynospam.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:\mysq l
datadir=d:\mysq l\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:\{Install Dir}\Embedded\d ebug.

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1847
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 above coding header I get frequent syntax errors with files that work flawlessly under Linux. The Syntax error usually appear near continuation lines of the form
8
1771
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; Public Function fileexists(Name As String) As Boolean On Error Resume Next Dim temp As String temp = Dir(Name, vbHidden Or vbSystem Or vbArchive Or vbReadOnly)
2
1822
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 anymore. I reentered it and didn't have any problems for a couple of days. Today I entered some coding, saved it, opened another database, and when I opened my original database again, the coding I had entered was missing. Access 2000 always...
144
6844
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 initiative. Typically I find that coding standards are written by some guy in the company who has a way of coding that he likes and then tries to force everybody else to write code the way he likes it, not for any rational reason, but simply for the...
20
1656
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 Source=C:\Temp\NW-test.MDB", everything works correctly when I run the project. However, if I set up the exact same connection using the DataAdapter wizard and try to run the project, I get a "Microsoft Jet database engine cannot open the file..." error.
86
2709
by: PTY | last post by:
Which is better? lst = while lst: lst.pop() OR while len(lst) 0:
0
1026
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 even using the form. I think its a problem in my coding, which is pasted below. Any help is greatly appreciated! Thanks! rivate Sub cmdFilter_Click()
0
1668
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 you wish to automate please send the standard to us in PDF format so we can assist in developing the automation with codecheck. If you are developing codecheck rule-files and have a particular
3
1133
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 view is a calculated field not stored in the database. It needs to be calculated when any of 3 columns in the datagrid are changed. problem 1: What event for the datagrid is triggered when a cell is modified AFTER it has loaded?...
1
2465
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 validate the data entered into the username and password fields stored in a table. This is not the problem, the problem is getting it to open a different form for a manager or for a member of staff dependant on the access level stored in the same table...
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8546
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.