Must I still use addslashes with PEAR DB?

This is a discussion on Must I still use addslashes with PEAR DB? within the PHP Language forums, part of the PHP Programming Forums category; Hi! I now use the DB classes from PEAR with mysql. Do I still have to use addslashes? I ask, ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-29-2004
Joe Randstein
 
Posts: n/a
Default Must I still use addslashes with PEAR DB?

Hi!
I now use the DB classes from PEAR with mysql. Do I still have to use
addslashes?
I ask, because I get some very strange results, I get slashes in front
of every " and they get saved in my database :-(

Now my hoster has turned magic_quotes_gpc on anyway. As a workaround:
On a PHP-environment where magic_quotes_gpc is turned on, can I do
stripslashes on every request-data without danger?

Or what is the recommended way to safely insert request-data into
mysql with PEAR?

Thanks for your answer
Reply With Quote
  #2 (permalink)  
Old 04-29-2004
Andy Hassall
 
Posts: n/a
Default Re: Must I still use addslashes with PEAR DB?

On 29 Apr 2004 07:38:49 -0700, javawocky@hotmail.com (Joe Randstein) wrote:

>I now use the DB classes from PEAR with mysql. Do I still have to use
>addslashes?
>I ask, because I get some very strange results, I get slashes in front
>of every " and they get saved in my database :-(
>
>Now my hoster has turned magic_quotes_gpc on anyway. As a workaround:
>On a PHP-environment where magic_quotes_gpc is turned on, can I do
>stripslashes on every request-data without danger?
>
>Or what is the recommended way to safely insert request-data into
>mysql with PEAR?


Using PEAR's placeholder emulation, without adding slashes. Prepare a
statement using ? for the placeholders and bind the data you want saved without
any modification.

Do not embed values in the SQL statement.

INSERT INTO t (c) values (?) -- correct
INSERT INTO t (c) values ('?') -- wrong, most of the time
INSERT INTO t (c) values ('$val') -- very wrong

http://pear.php.net/manual/en/packag...ro-execute.php

--
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 08:46 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0