Skip to Content.
Sympa Menu

freetds - RE: [freetds] PHP: Inserts with Unicode

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] PHP: Inserts with Unicode
  • Date: Wed, 21 Jan 2004 10:43:07 -0500

> From: Marco Brinkmann [mailto:marco_brinkmann AT gmx.net]
> Sent: January 21, 2004 3:26 AM
>
> I use RedHat 8.0, MSSQL2000, PHP4.3.3 and FreeTDS (version 8.0; client
> charset: UTF-8).
>
> I can read and display all NTEXT and NVARCHAR-Fields from
> MSSQL correctly.
> But if I try to write the read data into the database I get
> always the parse
> error "Unclosed quotation mark...".
>
> The Insert looks like...
>
> db("INSERT INTO table (test) (N'".addslashes($read)."')");
>
> If I echo the SQL and use it in the Enterprise Manager
> everything works correctly. Any clues?

In EM, do you say:

INSERT INTO table (test) (N'".addslashes(data)."')
or
INSERT INTO test values (N'.addslashes(data).')

The former is bad syntax afaik.

Either way, the quotes are unambiguous. I don't use PHP, but I would
suspect that when PHP is fed:
db("INSERT INTO table (test) (N'".addslashes($read)."')");

it might see:

db("INSERT INTO table (test) (N'"

I imagine you're trying to interpolate $read into the query text. Are the
second set of double quotes really needed? Would either of these work
instead?

db("INSERT INTO table (test) (N'.addslashes($read).')");
db("INSERT INTO table (test) (N\'.addslashes($read).\')");

HTH. The SQL still looks wrong to me, though.

--jkl

-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.






Archive powered by MHonArc 2.6.24.

Top of Page