Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 19th, 2001, 02:27 AM
midget2000x midget2000x is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 17 midget2000x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 45 sec
Reputation Power: 0
escaping illegal characters for MySQL with perl

I'm a newbie...

coded a little perl script to post form data to MySQL database. I'm wondering if I need to add any perl code to the posted data that will escape any illegal characters before it gets written to the database. Is there standard code already written for this purpose? Sorry if this has been covered. i searched and didn't come up with anything.

thanks!

Reply With Quote
  #2  
Old June 19th, 2001, 05:38 AM
mickalo's Avatar
mickalo mickalo is offline
Ole` Timer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: N.W. Iowa
Posts: 469 mickalo User rank is Private First Class (20 - 50 Reputation Level)mickalo User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 5 h 19 sec
Reputation Power: 8
Send a message via AIM to mickalo Send a message via MSN to mickalo
Thumbs up

I assume that your using DBI to access the db. Try using DBI's $dbh ->quote();, or use place holders.

Mickalo
__________________

Thunder Rain Internet Publishing

Custom Programming & Database development
Providing Personal/Business
Internet Solutions that work!

Reply With Quote
  #3  
Old June 20th, 2001, 02:03 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
Yes, you should always use dbi and the quote() or place holders method. If you're using something other then dbi (first of all, you'd be a fool ), you could just use a regex to do it (note: all this does it backtick '):
Code:
$var =~ s|'|\\'|g;

Reply With Quote
  #4  
Old June 20th, 2001, 10:11 AM
midget2000x midget2000x is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 17 midget2000x User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 16 m 45 sec
Reputation Power: 0
Thanks for the replies. Unfortunately I'm not 100% sure how this works, and can't seem to find more information on it's use. Do you just re-assign the variable like this, or is it different?

$var = "big mamma's house";
$var = $dbh->quote($var);

Thanks again!

Rory

Reply With Quote
  #5  
Old July 2nd, 2001, 10:44 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 10
Yes, that is the correct usage.
__________________
Jon Coulter
ledjon@ledjon.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > escaping illegal characters for MySQL with perl


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT