473,385 Members | 1,375 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,385 software developers and data experts.

How to insert a variable in a database which is calculated by 3 form fields

4
Hello all

Im having an issue trying to insert a variable in to a database.
This variable is the math result of 3 fields of the form, a division multiplied by a number.

So far is returning always 0 so i thought you might gime me a hand here

This is the cold below :

Expand|Select|Wrap|Line Numbers
  1. // declare variables to be inserted
  2. $venzini_kinisis_1 = ($_REQUEST['15']/$_REQUEST['8']) * $_REQUEST['1'];
  3. $venzini_100ara = ($_REQUEST['16']/$_REQUEST['9']) * $_REQUEST['2'];
  4. $venzini_super_1 = ($_REQUEST['17']/$_REQUEST['10']) * $_REQUEST['3'];
  5. $venzini_95_1 = ($_REQUEST['18']/$_REQUEST['11']) * $_REQUEST['4'];
  6. $venzini_95_2 = ($_REQUEST['19']/$_REQUEST['12']) * $_REQUEST['5'];
  7. $venzini_super_2 = ($_REQUEST['20']/$_REQUEST['13']) * $_REQUEST['6'];
  8. $venzini_kinisis_2 = ($_REQUEST['21']/$_REQUEST['14']) * $_REQUEST['7'];
  9.  
  10. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "insert_form")) {
  11. $insertSQL = sprintf("INSERT INTO kiniseis (polisi_kinisis_1, polisi_100aras, polisi_super_1, polisi_95_1, polisi_95_2, polisi_super_2, polisi_kinisis_2) VALUES (%s, %s, %s, %s, %s, %s, %s)",
  12.  
  13. GetSQLValueString($_POST['".$venzini_kinisis_1"'], "double"),
  14. GetSQLValueString($_POST['".$venzini_100ara"'], "double"),
  15. GetSQLValueString($_POST['".$venzini_super_1"'], "double"),
  16. GetSQLValueString($_POST['".$venzini_95_1"'], "double"),
  17. GetSQLValueString($_POST['".$venzini_95_2"'], "double"),
  18. GetSQLValueString($_POST['".$venzini_super_2"'], "double"),
  19. GetSQLValueString($_POST['".$venzini_kinisis_2"'], "double"));
Thanks in advance :)
Jul 13 '10 #1
2 1278
BOMEz
40
Are you sure that at no point in time one of your variables which is a denominators is a 0? If it is then it could cause you to get 0.

Try simply echoing all of the variables to actually see what their values are
Jul 13 '10 #2
ORB30
4
i use @ to avoid that thing :) so not to receive a notice from php "division by zero" i will echo and get back to see what is happening
Jul 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Emmett Power | last post by:
Hi, I have a small online survey in two parts designed to allow users to rank a few organisations that they have dealings with from a large list of organisations. I want the users to be able to...
4
by: Paxton | last post by:
At the risk of being told "If it ain't broke, don't fix it", my code works, but is ugly. Part of the admin site I'm working on at the moment includes a facility for users to enter Formulations...
2
by: Gawie Marais | last post by:
hi all, i have a form and would like to check two fields. if field 1 containes the letter 'c' and the other field contains 'undefined', then an error should apprear ina box on the screen. can...
1
by: dm_dal | last post by:
I'm looking for some feedback or for someone to point me in a good direction. We have a web application that consist of many forms. Some of our clients have asked if we can configure the app in...
4
by: MicroMoth | last post by:
Hi, I'm trying to write a update method, in which when the user clicks the update button the update method is passed 10 form fields. Then a update SQL is run to update the database. My question...
4
by: BLACKDOG157 | last post by:
I have to make a form with a variable number of textboxes. If, in the previous screen, the user chose a 2 day hotel stay, I need to input the number of rooms for 2 days. But if in the previous...
7
by: Dan | last post by:
(Using Classic ASP & MS Access) I have a page that has 120 fields on it (mostly checkboxes). I cannot split this into smaller pages. So what i want to do is write a class that handles this. in...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have some select fields in a form I created for a...
1
by: Rick Owen | last post by:
Greetings, I have a form that, when submitted, calls a plsql procedure. The form has a number of fields (text, hidden, select, radio) but the particular field that is giving me problems is a...
0
by: studentofknowledge | last post by:
hi my knowledgeable comrads I have created a web form using html, css with the addition of some basic javascript validation. Although now im having trouble to insert this information to my local...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.