Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Strange leading character
Jack wrote:

> Jack wrote:
> 
> Sorry
> 
> I just found that the value of $mycustcode contains a leading space,
> thus sql failed to match the right record.
> This also explained why the first element has  no such problem.
> Sorry for being so careless.
>
I tried to remove the leading space, but the regular expression failed
to remove it. It may be not a whitespace, what what is it?
Here is the html string being passed to the $in{'outlets'} perl code:
outlets=07-6-0057%2C&outlets=07-3-0051%2C&outlets=07-2-0036
What is %2C here?

The code I used to strip the white space is:
$str =~s/[ ]//g;

Thanks
Sam
 

Report this thread to moderator Post Follow-up to this message
Old Post
sam
12-29-04 08:57 AM


Re: Strange leading character
sam wrote:

> Jack wrote:
> 
> I tried to remove the leading space, but the regular expression failed
> to remove it. It may be not a whitespace, what what is it?
> Here is the html string being passed to the $in{'outlets'} perl code:
> outlets=07-6-0057%2C&outlets=07-3-0051%2C&outlets=07-2-0036
> What is %2C here?

%2C == the comma character.

> The code I used to strip the white space is:
> $str =~s/[ ]//g;

Better:

$str =~ s/\s+//g;

You may also want to try passing the string through Data::Dumper to
make sure you know exactly what character it is (if it's non-printable,
Data::Dumper may translate it to printable for you).

Also, you really should stop putting values in your SQL.  As much as
possible, that is.

$create_view_stmt = qq{create view $viewtab as
select c.custcode, c.custname, c.type, sum(t.netsales) as sales from
customer c, transaction t
where c.custcode = t.custcode
and date(t.date) >= ?
and date(t.date) <= ?
and c.type in (?,?)
and c.custcode = ?
group by c.custcode};


Then, when you go to execute this:

$res = $sth->execute($start_date,
$end_date,
qw(EXPORT LOCAL),
$mycustcode);

Then you don't need to worry about special character as much.  (Stray
characters are a different problem no matter how you do things.)

I would prefer putting a placeholder in for the view name, too, but I
doubt many (if any?) database vendors support that.  If any do, it's
unlikely MySQL does.

Then again, MySQL may not even support this much for a create statement
- I'm not too sure.  Then I presume you're using the DBI 'quote'
function to hide special characters properly?

Report this thread to moderator Post Follow-up to this message
Old Post
Darin McBride
12-29-04 08:57 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:59 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.