473,789 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

list and explode

Hello,

I have been searching for a reason for this behavior but no solution
so I figured I would ask.

Basically I have a web page that displays data in a database to the
user for updates/deletion/addition. For each data field ont he web
page I put the data from the database in the field name with teh field
name and data seperated by a |. ex: address|35 Elm St.

I then loop thru all the fields on the form and if the data in the
field name doesnt match the data submitted then update the database.
Here is the code:

foreach ($_REQUEST as $curFld => $Data) {
if ($curFld <> 'Submit') {
list ($field, $orig_data, $table, $id) = explode('|', $curFld);

if ($orig_data <> $_POST[$curFld]) {
//UPDATE DATABASE
$sql = "UPDATE $table SET $field = '".$_POST[$curFld]."' WHERE
ID = $id";
$result = mysql_query($sq l, $_SESSION['conn']) or
die(mysql_error ());
}
}
}

Here is the problem, either list() or explode() is replacing all
spaces in $orig_data with underscores so 35 Elm St. becomes
35_Elm_St.. This causes the code to always update this field and any
others where this occurs. Obviously I could do this str_replace("_" ,
" ", $orig)data) to fix this problem but if the user wants to use
underscores I dont want to replace them. (Address is not the only
field on the page.

Thanks in advance.

Mark
Jul 17 '05 #1
3 2911
why not just update all teh data, changed or not?
"Mark" <ma********@myr apidsys.com> wrote in message
news:58******** *************** ***@posting.goo gle.com...
Hello,

I have been searching for a reason for this behavior but no solution
so I figured I would ask.

Basically I have a web page that displays data in a database to the
user for updates/deletion/addition. For each data field ont he web
page I put the data from the database in the field name with teh field
name and data seperated by a |. ex: address|35 Elm St.

I then loop thru all the fields on the form and if the data in the
field name doesnt match the data submitted then update the database.
Here is the code:

foreach ($_REQUEST as $curFld => $Data) {
if ($curFld <> 'Submit') {
list ($field, $orig_data, $table, $id) = explode('|', $curFld);

if ($orig_data <> $_POST[$curFld]) {
//UPDATE DATABASE
$sql = "UPDATE $table SET $field = '".$_POST[$curFld]."' WHERE
ID = $id";
$result = mysql_query($sq l, $_SESSION['conn']) or
die(mysql_error ());
}
}
}

Here is the problem, either list() or explode() is replacing all
spaces in $orig_data with underscores so 35 Elm St. becomes
35_Elm_St.. This causes the code to always update this field and any
others where this occurs. Obviously I could do this str_replace("_" ,
" ", $orig)data) to fix this problem but if the user wants to use
underscores I dont want to replace them. (Address is not the only
field on the page.

Thanks in advance.

Mark

Jul 17 '05 #2
"Mark" <ma********@myr apidsys.com> wrote in message
news:58******** *************** ***@posting.goo gle.com...
Hello,

I have been searching for a reason for this behavior but no solution
so I figured I would ask.

Basically I have a web page that displays data in a database to the
user for updates/deletion/addition. For each data field ont he web
page I put the data from the database in the field name with teh field
name and data seperated by a |. ex: address|35 Elm St.


You have a race hazard the size of Texas, man. Just update all the fields.
Jul 17 '05 #3
I am currently doing that and in less than one day we had more than
900,000 updates to the database. So I would like to avoid any
uneccessary updates.

"Alexander Ross" <al******@bleen .net> wrote in message news:<nWifc.142 603$K91.356452@ attbi_s02>...
why not just update all teh data, changed or not?
"Mark" <ma********@myr apidsys.com> wrote in message
news:58******** *************** ***@posting.goo gle.com...
Hello,

I have been searching for a reason for this behavior but no solution
so I figured I would ask.

Basically I have a web page that displays data in a database to the
user for updates/deletion/addition. For each data field ont he web
page I put the data from the database in the field name with teh field
name and data seperated by a |. ex: address|35 Elm St.

I then loop thru all the fields on the form and if the data in the
field name doesnt match the data submitted then update the database.
Here is the code:

foreach ($_REQUEST as $curFld => $Data) {
if ($curFld <> 'Submit') {
list ($field, $orig_data, $table, $id) = explode('|', $curFld);

if ($orig_data <> $_POST[$curFld]) {
//UPDATE DATABASE
$sql = "UPDATE $table SET $field = '".$_POST[$curFld]."' WHERE
ID = $id";
$result = mysql_query($sq l, $_SESSION['conn']) or
die(mysql_error ());
}
}
}

Here is the problem, either list() or explode() is replacing all
spaces in $orig_data with underscores so 35 Elm St. becomes
35_Elm_St.. This causes the code to always update this field and any
others where this occurs. Obviously I could do this str_replace("_" ,
" ", $orig)data) to fix this problem but if the user wants to use
underscores I dont want to replace them. (Address is not the only
field on the page.

Thanks in advance.

Mark

Jul 17 '05 #4

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

Similar topics

7
3089
by: Craig Keightley | last post by:
is it possible to compare acomma separated list aginst another eg comma list 1 => 1,2,3,4,5 comma list 2 => 3,5 can you check that 3 is in both, and 5 is in both, therfore they match??? the comparison is to check that if product a who supplies products 1,2,3,4,5 can be used instead of product b who supplies 3,5 as product a already supplies them
1
2229
by: Craig Keightley | last post by:
I can do the match perfectly but what i also need to do is create a third list of comma separated values that are in both eg: List 1 => 1,2,3,4,5,6,7,8,11 List 2 => 1,3,4,5,6,7,10,23 Therefore
4
9119
by: blrmaani | last post by:
Here is what I want: string s1 = "This is a list of string"; list<string> s2 = s1.some_method(); Now, I should be able to traverse list s2 and get each member ( which is of type 'string' ). I know that this can be achieved using strtok. But I was wondering
12
2918
by: frizzle | last post by:
Hi there, i have a site with fake folders & files. htaccess rewrites everything to index.php?vars now in index.php i decide what file to include with a switch/case statement. to define where i am, i explode the query string, and check $array where i am for the main section. Only now if there are two slashes behind each other
5
3463
by: FFMG | last post by:
Hi, I need the php equivalent of explode in one of my app. I read a very big file and "explode" each line to fill a structure. The reading of the file, 19Mb, (I will also need to streamline the way I read each line I guess), takes about 10 seconds. But when I 'explode' each line the process takes about 140 seconds. This is what I have tried so far...
6
38227
by: oskar | last post by:
Hello everyone. I have a problem with my program... and i kinda dunno what to do.. everything seems to work ok, but i'm getting corrupted double-linked list error =\. *** glibc detected *** corrupted double-linked list: 0x080aff40 *** Program received signal SIGABRT, Aborted. 0xaf7037b2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 (gdb) bt #0 0xaf7037b2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
2
1361
by: Kirkingly | last post by:
I want to create the following print_r results into a dynamic select list.. I have tried something like: <?php $prefixes = array(explode("\n", $board)); echo '<select name="tprefix">'; for($i = 0; $i < count($prefixes); $i++) { echo '<option value="'.$i.'">'.$prefixes.'</option>'; }
5
3288
by: sathyashrayan | last post by:
Dear group, The function to be used as follows: $links = "http://www.campaignindia.in/feature/analysis"; $tag1 = '<div class=feature-wrapper>'; $tag2 = '<h1><a href'; $tag3 = "</a>"; $op = doGetTags($links,"START",$tag1,$tag2,$tag3,"END");
7
16448
by: Michael Sharman | last post by:
Is there a PHP function which can add single quotes around each item in a list? So if I have: $myList = "michael,frank,peter,sally,june"; What I want to end up with is: $myList = "'michael','frank','peter','sally','june'";
0
9656
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
9502
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,...
0
10383
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9971
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
7521
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
6751
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
5406
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
5541
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4080
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 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.