Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #13838

Re: solved

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.php
Subject Re: solved
Date 2014-06-13 20:50 +0000
Organization A noiseless patient Spider
Message-ID <lnfo73$uke$2@dont-email.me> (permalink)
References (1 earlier) <itrvizyykmyu$.1m8xc48h8xvgi.dlg@40tude.net> <lnf0vd$e2n$1@dont-email.me> <1dix54w7x6apy$.1jl70bauvt0a0$.dlg@40tude.net> <lnfhr0$e8v$1@dont-email.me> <157nwayhe47ig.1exa9x5yqxi59$.dlg@40tude.net>

Show all headers | View raw


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@gmail.com

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

function for preserving special characters? richard <noreply@example.com> - 2014-06-13 00:57 -0400
  Re: function for preserving special characters? Tim Streater <timstreater@greenbee.net> - 2014-06-13 10:03 +0100
    Re: function for preserving special characters? Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-13 15:32 +0200
      Re: function for preserving special characters? Tim Streater <timstreater@greenbee.net> - 2014-06-13 14:42 +0100
        Re: function for preserving special characters? Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-13 16:26 +0200
          Re: function for preserving special characters? Tim Streater <timstreater@greenbee.net> - 2014-06-13 18:23 +0100
  Re: function for preserving special characters? Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-13 10:39 +0000
    Re: function for preserving special characters? Paul Herber <paul@pherber.com> - 2014-06-13 12:37 +0100
      Re: function for preserving special characters? Doug Miller <doug_at_milmac_dot_com@example.com> - 2014-06-13 12:59 +0000
      Re: function for preserving special characters? richard <noreply@example.com> - 2014-06-13 14:45 -0400
  solved  (was: function for preserving special characters?) richard <noreply@example.com> - 2014-06-13 09:57 -0400
    Re: solved Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-13 10:14 -0400
      Re: solved richard <noreply@example.com> - 2014-06-13 14:43 -0400
        Re: solved Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-13 15:01 -0400
          Re: solved richard <noreply@example.com> - 2014-06-13 15:44 -0400
            Re: solved Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-13 16:09 -0400
            Re: solved Tim Streater <timstreater@greenbee.net> - 2014-06-13 21:16 +0100
              Re: solved Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-13 16:38 -0400
                Re: solved richard <noreply@example.com> - 2014-06-13 18:29 -0400
                Re: solved Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-13 19:43 -0400
                Re: solved richard <noreply@example.com> - 2014-06-13 20:48 -0400
                Re: solved Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-13 21:39 -0400
                Re: solved Evan Platt <evan@theobvious.espphotography.com.invalid> - 2014-06-13 21:20 -0700
                Re: solved Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-14 19:50 +0000
              Re: solved richard <noreply@example.com> - 2014-06-13 18:23 -0400
                Re: solved Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-14 20:01 +0000
            Re: solved Denis McMahon <denismfmcmahon@gmail.com> - 2014-06-13 20:50 +0000
  Re: function for preserving special characters? Richard Damon <Richard@Damon-Family.org> - 2014-06-13 20:45 -0400
    Re: function for preserving special characters? Jerry Stuckle <jstucklex@attglobal.net> - 2014-06-13 20:51 -0400
      Re: function for preserving special characters? Richard Damon <Richard@Damon-Family.org> - 2014-06-13 22:08 -0400

csiph-web