Re: solved [message #186100 is a reply to message #186096] |
Fri, 13 June 2014 20:50 |
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
|
|
|