Hi There,
I am building a form that allows a business to enter at most 2 mailing addresses. i have the form set up so both inputs are there, storing as a post array. the problem is, when i try to use php to enter the data into in the mysql database, it enters empty data even when a field is null.
html -
<form method='POST' action='entry2.php' name='entry'>
-
<table>
-
<tr><td colspan='4' align='center'>Mailing Address</td></tr>
-
<tr><td>Street:<input type='text' name='mStreet[]' /></td><td>Zip:
-
<?php
-
selectDistinct($connection,'CityCode','zip','mzip[]','97465');
-
?>
-
</td></tr>
-
<tr><td>Street:<input type='text' name='mStreet[]' /></td><td>Zip:
-
<?php
-
selectDistinct($connection,'CityCode','zip','mzip[]','97465');
-
?>
-
</td></tr></table></form>
-
php to save to db -
if(!empty($mStreet)){
-
for($i=0;$i<2;$i++){
-
$Cityquery = "SELECT cityCode FROM CityCode WHERE zip='{$mzip[$i]}'";
-
if(!($result = @ mysql_query($Cityquery,$connection))){showerror();}
-
$row = mysql_fetch_array($result);
-
$mcityCode[$i] = $row['cityCode'];
-
$insertQuery = "INSERT INTO Address VALUES(NULL,1,'{$BID}','{$mStreet[$i]}','{$mcityCode[$i]}')";
-
if(!(@ mysql_query($insertQuery, $connection))){showerror();}
-
}
-
}
-
p.s. the selectDistinct functions return a list of zip codes that are accepted, and in the php it is used to determine the code that is associated with the zip
1 1305 hsriat 1,654
Recognized Expert Top Contributor
Why didn't you used $_POST[ ] ...?
And do the validation inside the for loop as[php]for ($i=0; $i<2; $i++)
{
if(isset($mStre et[$i]))
{
//save data to db
}
}[/php]
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: VK |
last post by:
A while ago I proposed to update info in the group FAQ section, but I
dropped the discussion using the approach "No matter what color the cat
is as long as it still hounts the mice". Over the last month I had
enough of extra proof that the cat doesn't hount mice anymore in more
and more situations. And the surrent sicretisme among array and...
|
by: !TG |
last post by:
I recently learned of Join
response.write join(ThisArray," ")
I am having trouble with it, however and it appears to be caused by null
characters.
Is there anyway around this join problem with Arrays containing Null?
|
by: Gertjan van Heijst |
last post by:
Hi,
I really hope someone can help me because I've already spend 2 days on
this problem and I'm not getting anywhere. I think the problem is that
I don't really understand how text boxes store 'empty' values. I'm
trying tot do the following.
I have a continous sub form that lists transactions. On the top level
form I have some text boxes...
|
by: Peter B. Steiger |
last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C
is a simple word game that involves stringing together random lists of
words. In the Pascal version the whole array was static; if the input
file contained more than entries, tough.
This time I want to do it right - use a dynamic array that increases in
size with...
|
by: j_ruez |
last post by:
I am trying to learn the best ways to do some things in c#
When testing for an empty string, what is the best way to test it.
For example, if I have a textbox named txtValue
Should I use
txtValue.Text == ""
or
| |
by: skumar434 |
last post by:
Hi everybody,
I am faceing problem while assigning the memory dynamically to a array
of structures .
Suppose I have a structure
typedef struct hom_id{
int32_t nod_de;
int32_t hom_id;
|
by: ggnguser |
last post by:
It's part of a test and I'm stumped. There is a function
void foo(char **x)
The function signature is given and cannot be changed, so no passing
of other values. The test case involves defining this variable:
char *y = { /* bunch of stuff */ }
and calling
|
by: Sunny |
last post by:
Hi, Can someone tell me, How to redefine array or make array empty or
null.
Here what I am trying to do.
var temp = new Array();
for(i=0; i <=outstring.length-1; i++) {
temp = outstring.split(',');
}
Once the for loop will finish doing it, I want temp array to be null
|
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...
|
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...
|
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...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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...
| |