NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL and spaces in data

Jeff jsiegel1 at optonline.net
Thu Jun 19 17:35:37 EDT 2003


Dan,

Thanks for your input...here's some more info on what I'm doing.

On Form 1 a car dealer selects a manufacturer, say, Audi and Alfa-Romeo.
On Form 2, I generate all of the models for these manufacturers and
provide a checkbox next to each model. 

To differentiate makes/models on the page I generate checkboxes that
look like the following:

<input name="ALFA-ROMEO|GTV-6" type="checkbox" value="1" checked >
<input name="ALFA-ROMEO|SPIDER VELOCE" type="checkbox" value="1">

First part gives me the manufacturer, second part gives me the model.

The problem is the Post data. For example, look what happens to the
Spider Veloce:
(I used var_dump)
  ["ALFA-ROMEO|1600_DUETTO_SPIDER"]

The post data has underscores.

But the other part of the issue is that the page posts to itself if
there is a data error and checks the various checkboxes depending on the
post data. In the case where the post data is ["ALFA-ROMEO|GTV-6"] it's
easy enough to do.

So...do I do something like a str_replace function to remove the
underscores?

Keep in mind that I'm on php 4.1.x and it does not have htmlentities nor
html_decode_entity.

Jeff

-----Original Message-----
From: Analysis & Solutions [mailto:danielc at analysisandsolutions.com] 
Sent: Thursday, June 19, 2003 11:23 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] MySQL and spaces in data


Hi Jeff:

On Thu, Jun 19, 2003 at 11:11:50AM -0400, Jeff wrote:
> 
> <input name="ALFA-ROMEO|1600 DUETTO SPIDER" type="checkbox" value="1">

While some folks have suggested using string replace functions on the 
incomming data, I beg to differ.

Text values like that aren't meant for name fields.  Perhaps swap the 
value and name fields?  Or for the name and/or value fields, use 
id numbers from the database.  The name could even be an array, such as:

   name="car[123]"

allowing your receiving script to loop through all of the "car" array 
elements with a foreach statement.

Without knowing the more context of what you're trying to do, it's hard
to 
give more solid guidance.

--Dan

-- 
     FREE scripts that make web and database programming easier
           http://www.analysisandsolutions.com/software/
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7th Ave #4AJ, Brooklyn NY    v: 718-854-0335   f: 718-854-0409


--- Unsubscribe at http://nyphp.org/list/ ---






More information about the talk mailing list