473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

always enable addslashes

Hi all,

Is there a way I can always enable addslashes by including a line of
code to the top of my pages?

Thanks in advance
Stijn

Dec 12 '06 #1
5 1743
If you have access to php.ini, you can set the magic_quotes_gpc
variable to "On". Alternatively, you can set it using the ini_set
function in your scripts (See: http://php.net/ini_set).

However, it would be better if you just escaped input on your own, and
having PHP automatically add slashes is a nuisance if you already do.

Curtis

On Dec 12, 1:48 am, "Tarscher" <tarsc...@gmail.comwrote:
Hi all,

Is there a way I can always enable addslashes by including a line of
code to the top of my pages?

Thanks in advance
Stijn
Dec 12 '06 #2
..oO(Curtis)
>If you have access to php.ini, you can set the magic_quotes_gpc
variable to "On".
Magic quotes are dead. They will be removed in PHP 6.
>However, it would be better if you just escaped input on your own
That's the only reliable and secure way. For example addslashes() can't
know what other escaping might be necessary when inserting data into a
database. That's why functions like mysql_real_escape_string() exist.

Micha
Dec 12 '06 #3
Curtis wrote:
However, it would be better if you just escaped input on your own, and
having PHP automatically add slashes is a nuisance if you already do
And PHP *not* adding slashes is a nuisance if you already use stripslashes().

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

Dec 12 '06 #4
Very good points, Michael and Toby, thanks for making those
additions.It's good to hear that it's going in PHP 6, I haven't been
keeping up too well on what's going on with PHP 6, so I'll have to
check out what's going on in more detail.

Dec 13 '06 #5
..oO(Curtis)
>Very good points, Michael and Toby, thanks for making those
additions.It's good to hear that it's going in PHP 6, I haven't been
keeping up too well on what's going on with PHP 6, so I'll have to
check out what's going on in more detail.
Old, but still interesting:

Minutes PHP Developers Meeting
http://www.php.net/~derick/meeting-notes.html

Micha
Dec 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John | last post by:
Hello. I want to get this blasted .htaccess file sorted out, so I can have sessions without register_globals being on. I have looked everywhere for info on this and I mean everywhere...
1
by: leegold2 | last post by:
When I look directly in my db field I see a difference between these two functions. The top line (seebelow) was inserted with addslashes vs. the bottom line where I used mysql_real_escape_string....
4
by: Jan Pieter Kunst | last post by:
Q. How do I use addslashes() and stripslashes() when dealing with HTML forms and database INSERTs, UPDATEs and SELECTs? A. It depends on the setting of the php.ini directive "magic_quotes_gpc"....
2
by: Marcus | last post by:
Hello, My php.ini file currently has magic quotes set to On, but I have read that it is better to code with it off. Currently with magic quotes on, I only use stripslashes() to properly...
2
by: Cruella DeVille | last post by:
I must have som errors in my understanding of strip- vs addslashes. I thought that if a user submitted eg a username, like this username=siv' drop database test; I should addslashes to escape ' and...
4
by: Areric | last post by:
hey all, I recently got in a bit of a fight with my webhost because he made some changes to my server. Specifically they updated php without telling me. They are now running PHP 4.4.1 (not sure...
5
by: lawrence k | last post by:
This seems so simple, I can't believe its tripping me up. I've a database class with a query method that looks like this: function query($query=false) { global $controller; // $query =...
15
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
Hello folks, I need some help/advice FAST. I have problems with addslashes on my web-servers. After uploading a file, I read the uploaded file, use addslashes on the read data and then insert...
5
by: Gilles Ganault | last post by:
Hello As the user may type strings that contain verboten characters like apostrophes, I need to go through the $_POST array, and use addslashes() on each and every item But it doesn't make...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.