List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:November 23 1999 7:59pm
Subject:Re: Single quote entry
View as plain text  
At 11:35 AM -0500 11/23/99, brian wrote:
>Still fairly new to the MySQL game so forgive me if this has been answered
>many times before.
>(A little info )
>I'm running :
>BSDI 4.1 (Unix)
>Mysql 3.22.27
>Apache 1.3.9
>(My Problem)
>When I try to INSERT multiple lines into my table with an entry that has a
>single quote in one of the values (such as a possessive quote like "brian's
>table") I get an sql error on the line following the entry with the single
>According to documentation I should use a '\' so that mysql will take the
>single quote literally.
>(Some Examples)
>INSERT INTO data VALUES( 'Adam\'s', '1984 - Present', 'Brian Basset',
>'Universal Press Syndicate', 'Humor', '');
>INSERT INTO data VALUES( '9 Chickweed Lane', 'Present', 'Brooke McEldowney',
>'unknown', 'Humor', '');
>(Gives me an error on the second entry like this "MySQL said: You have an
>error in your SQL syntax near '; INSERT INTO data VALUES( '9 Chickweed
>Lane', 'Present', 'Brooke McEldowney', ' at line 1.")

Look closely at the error message.  It's telling you that the error occurs
at the semi-colon, *not* on the second statement.

I assume that you're trying to pass multiple INSERT statements as a query
string in a PHP script (from your description above)?  You can't do that.
mysql_query() accepts a single query.  And you don't add a semicolon
to the end of the query.  That's a convention for the mysql client, not
for PHP.

Paul DuBois, paul@stripped
Single quote entrybrian23 Nov
  • RE: Single quote entrybrian23 Nov
  • Re: Single quote entryJeff Thies23 Nov
  • Re: Single quote entryPaul DuBois23 Nov