FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » function for preserving special characters?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: solved [message #186100 is a reply to message #186096] Fri, 13 June 2014 20:50 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Fri, 13 Jun 2014 15:44:58 -0400, richard wrote:

> What's going to happen when you say:
> insert into tabe VALUES('it's').
> PHP, not mysqli, kicks back an error right?

No. the mysql rdbms kicks the error back to through the mysqli interface
to php.

PHP really doesn't care what you put in a string.

mysqli->query() (or mysqli_query()) just takes the string you give it and
passes it to the mysql rdbms as an sql command.

If the string that you assembled in php and passed to the mysql rdbms
using the mysqli interface is not a valid sql statement, then the mysql
rdbms indicates this by returning an error value to the mysqli interface
code which is then passed back to php by setting the result of the mysqli-
> query() (or mysqli_query()) call to false, and also setting an error
number and an error string which can be retrieved with other appropriate
mysqli_*() (or mysqli->*()) calls.

> PHP sees the third single quote as a mismatch.

No, PHP isn't seeing the single quote as a mismatch, mysql is seeing the
single quote as a mismatch. That's why you're getting a mysql error and
not a php error.

> To correct this, you must include a \.
> Insert into table VALUES('it\'s') is now acceptable.

It might appear to be working in this instance, but it is not the correct
way to do this. Have you actually checked that the data that ends up in
the table is what you're assuming it is?

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Oracle Wallet and PHP issue.
Next Topic: What is the purpose of "&" in this code?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 18:46:13 GMT 2024

Total time taken to generate the page: 0.04583 seconds