php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3707 Inserting the ' char into a mysql table
Submitted: 2000-03-02 11:00 UTC Modified: 2000-03-03 11:11 UTC
From: ronen at aai dot co dot il Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0 Latest CVS (02/03/2000) OS: Unix
Private report: No CVE-ID: None
 [2000-03-02 11:00 UTC] ronen at aai dot co dot il
It is not possible to insert the  '   char (Ascii code = 39) into  a mysql table.

for example:
$CooperationDescription = "children's books";
$setstring =  " CooperationDescription = '$CooperationDescription' ";


$result = mysql ("password","UPDATE Tbl  SET  $setstring WHERE (CNumber = $CNumber) ");
in this case the data will not be inserted or updated .
and $result will be equal to "".

if you need more information please contact me :
E MAIL: ronen@aai.co.il

Please email to me an  answer anyway.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-02 11:07 UTC] ronen at aai dot co dot il
please dont tell me that it can be changed if we use the ereg_replace :
ereg_replace(39,135,$text);
beacuse  this is not a good sulotion.

 [2000-03-02 11:41 UTC] joey at cvs dot php dot net
You need to backslash escape the ' char.

You can use any of the following

Turn on magic quotes (http://www.php.net/manual/configuration.php3)
addslashes (http://www.php.net/manual/function.addslashes.php3)
e/preg to replace ' with \'

and so on...

 [2000-03-03 05:06 UTC] ronen at aai dot co dot il
thank you very much for your replay.
this solution is not good beacuse i cant tell my costumers 
please enter the \ before evrey ' this is somthing that should be 
in the php3 automatically , it has to be somthing that the user doesnt 
know about.

so my bug is open again
ronen
 [2000-03-03 11:11 UTC] mrobinso at cvs dot php dot net
Please *read the manual* on the addslashes function:

http://www.php.net/manual/function.addslashes.php3

This is not a bug.
The previous suggestion on this solution was accurate.
This function automagically adds the slashes for you,
no need for the users to manually type them in.

If you wish to have this happen without using the
addslashes function, you can turn on the 'magic-quotes'
directive in your php3.ini file.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 21:01:31 2024 UTC