/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] What is the difference between….

Ok, I have a simple question. I was looking over my code and for some reason when I use mysql_real_escape_string() and try to enter data into a table nothing gets entered but when I use mysql_escape_string() data does get entered and when I run phpinfo() it tells me that I have php5.2 installed. What is the difference between those two functions? Is there anything different that I need to worry about or will either work just as good as the other?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NightShift58Jan 09.2007 — This function is identical to mysql_real_escape_string() except that mysql_real_escape_string() takes a connection handler and escapes the string according to the current character set. mysql_escape_string() does not take a connection argument and does not respect the current charset setting.[/quote]Do you have an established connection to a database at that point?

P.S. Sorry: http://us2.php.net/manual/en/function.mysql-real-escape-string.php
Copy linkTweet thisAlerts:
@polorboyauthorJan 09.2007 — That did it, I had it assigning mysql_real_escape_string() to the variables before connecting, when I moved that to after connecting it works. Why is that?
Copy linkTweet thisAlerts:
@NightShift58Jan 09.2007 — ... because [b]mysql_escape_string()[/b] just escapes the string whereas [b]mysql_real_escape_string()[/b] first talks to the SQL server to find out if there are any "special" instructions - so to say...
Copy linkTweet thisAlerts:
@polorboyauthorJan 09.2007 — Oh, ok, cool. Well, that answers that. Thanks a bunch.
Copy linkTweet thisAlerts:
@NightShift58Jan 09.2007 — You're welcome!
×

Success!

Help @polorboy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...