Hi all,
I was wondering if it is possible to format variables from within the VALUES
section of a mysql INSERT string.
I have some variables that are passalong from a script and get deposited to
a mysql db.
since end users can submit in all uppercase or lower case, i was looking for
some data normalization.
so I am going to apply ucwords(strtolo wer($variable1) );
but in the name of keeping the script as small and sweet as possible can i
do
mysql_query ("INSERT INTO 10m (firstname, lastname, zipcode, email, 10mdate,
entrydate, termsagree)
VALUES ('ucwords(strto lower($firstnam e));',
'ucwords(strtol ower($variable1 ));', '$zipcode', '$email',
'$month--$day-$year', '$entrydate', '$termsagree')" );
etc etc.
or do i have to do
$fixed_variable 1=ucwords(strto lower($variable 1));
$fixed_variable 2=ucwords(strto lower($variable 2));
mysql_query ("INSERT INTO 10m (firstname, lastname, zipcode, email, 10mdate,
entrydate, termsagree)
VALUES ('$fixed_firstn ame', '$fixed_lastnam e', '$zipcode',
'$email', '$month--$day-$year', '$entrydate', '$termsagree')" );
i think you get the idea.
i would prefer the former vs the latter since there are about 10 variables
to rewrite....
Cheers,
Gary
Curwe.com
I was wondering if it is possible to format variables from within the VALUES
section of a mysql INSERT string.
I have some variables that are passalong from a script and get deposited to
a mysql db.
since end users can submit in all uppercase or lower case, i was looking for
some data normalization.
so I am going to apply ucwords(strtolo wer($variable1) );
but in the name of keeping the script as small and sweet as possible can i
do
mysql_query ("INSERT INTO 10m (firstname, lastname, zipcode, email, 10mdate,
entrydate, termsagree)
VALUES ('ucwords(strto lower($firstnam e));',
'ucwords(strtol ower($variable1 ));', '$zipcode', '$email',
'$month--$day-$year', '$entrydate', '$termsagree')" );
etc etc.
or do i have to do
$fixed_variable 1=ucwords(strto lower($variable 1));
$fixed_variable 2=ucwords(strto lower($variable 2));
mysql_query ("INSERT INTO 10m (firstname, lastname, zipcode, email, 10mdate,
entrydate, termsagree)
VALUES ('$fixed_firstn ame', '$fixed_lastnam e', '$zipcode',
'$email', '$month--$day-$year', '$entrydate', '$termsagree')" );
i think you get the idea.
i would prefer the former vs the latter since there are about 10 variables
to rewrite....
Cheers,
Gary
Curwe.com
Comment