top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

significance of escape character in string in PHP

0 votes
413 views

I am having an string which was have few ' (single quote) and few " (double quotes) and was not able to insert into the mysql database. I have replaced them with \' and \" and everything is fine.
Though this are fine now but don't understand the working and I could have missed few corner cases also. Please suggest the working and also if there is some better way to achieve this.

posted Mar 18, 2013 by Salil Agrawal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

You should be using either mysql_real_escape_string or mysqli_real_escape_string (preferably the
later) depending on how you're accessing the DB.

answer Mar 18, 2013 by anonymous
0 votes

The mysql extension is officially not recommended for writing new
code, so anyone using it should be informed of this fact. I think it
should consist of more than "don't use that," but at the very least
that should cause the questioner to want to know why.

http://php.net/intro.mysql

This issue is problematic for exactly the reason Salil demonstrates
above: "it's working." Great that in this case it hasn't been left at
that, but most will see it work and think they've "got it right."

answer Mar 18, 2013 by anonymous
Similar Questions
0 votes

Have two questions -
1. How to find type of a variable in PHP.
2. How to find the type of an array in PHP.

Please help.

0 votes

I have downloaded HipHop for my website, I am going through various web links which are suggesting that performance will improve 3-6 times. However I don't know the Stability of the HipHop.

Please provide your inputs so that I can decide to use HipHop.

+1 vote

I have a web application written in PHP. It have been running for several years. Now I want to run it as a stand-alone application on an Android smartphone or tablet. How can I do it?

0 votes

My webcode written in PHP and it is running in the interpreted way. My problem is it is not giving the desired performance so want to try the compiler if any.
Please suggest if we have any compiler option available for the PHP code and more important is this new option.

...