List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:April 29 2002 1:09pm
Subject:Re: mysql_real_query and escaping a semicolon
View as plain text  
The semicolon does not belong there.


Anna Fowles-Winkler wrote:

>Anna Fowles-Winkler wrote:
>
>>Paul DuBois wrote:
>>
>>>>Paul DuBois wrote:
>>>>
>>>>> At 14:37 -0600 4/26/02, Anna Fowles-Winkler wrote:
>>>>> >Well, the function is called like this:
>>>>> >
>>>>> >mysql_real_query( mysql_connection, query_string, strlen(
> query_string ));
>>>>> >
>>>>> >Wouldn't that pass the correct length?
>>>>>
>>>>> Not necessarily.
>>>>>
>>>>Uhm... why not?  Wouldn't strlen return the length of the string, ie, the
>>>>number of characters, and wouldn't that be the length in bytes?
>>>>
>>>>--Anna
>>>>
>>>Because mysql_real_query() allows the possibility that the query
>>>string contains binary data (including null bytes), in which case
>>>strlen() won't necessarily be correct.
>>>
>>>*IF* the query string doesn't have anything like that in it,
>>>then your call should work.  I just find it hard to believe that
>>>a semicolon would cause any problem.
>>>
>>The query string doesn't have anything binary, and the call doesn't work.  I get
> a
>>syntax error right before the semicolon.
>>
>>This is my query string:
>>INSERT INTO micromodels
>> (name, revision, dynamic, m_class, novars, equation, min_0, min_1,
>> min_2, min_3, min_4, min_5, min_6, min_7, min_8, max_0, max_1,
>> max_2, max_3, max_4, max_5, max_6, max_7, max_8, except_0,
>> except_1, except_2, except_3, except_4, except_5, except_6,
>> except_7, except_8, prompt_0, prompt_1, prompt_2, prompt_3, prompt_4,
>> prompt_5, prompt_6, prompt_7, prompt_8, allow_0, allow_1, allow_2,
>> allow_3, allow_4, allow_5, allow_6)
>>   VALUES ('Eye Movement
>>Time',1,NULL,'per',0,'.1;',0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,0,0,0,0,1);
>>
>>And I get this error:
>>
>>You have an error in your SQL syntax near ' '1.' at line 10
>>
>>Kind of weird.  I tried upping the strlen by 1, and that didn't work either.
>>
>>Thanks for any suggestions,
>>Anna
>>
>
>To make it more interesting, I can submit the query into MySQL either thru the command
> line monitor or thru a -e mysql command line call (mysql -uuser
>-ppassword -e "query"), and it works fine!
>
>--Anna
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>   http://www.mysql.com/manual.php   (the manual)
>   http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <mysql-thread107303@stripped>
>To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


Thread
mysql_real_query and escaping a semicolonAnna Fowles-Winkler26 Apr
  • Re: mysql_real_query and escaping a semicolonPaul DuBois26 Apr
  • Re: mysql_real_query and escaping a semicolonAnna Fowles-Winkler26 Apr
    • Re: mysql_real_query and escaping a semicolonPaul DuBois26 Apr
  • Re: mysql_real_query and escaping a semicolonAnna Fowles-Winkler26 Apr
    • Re: mysql_real_query and escaping a semicolonPaul DuBois26 Apr
  • Re: mysql_real_query and escaping a semicolonAnna Fowles-Winkler26 Apr
  • Re: mysql_real_query and escaping a semicolonAnna Fowles-Winkler26 Apr
  • Re: mysql_real_query and escaping a semicolonGerald Clark29 Apr
  • Re: mysql_real_query and escaping a semicolonAnna Fowles-Winkler29 Apr
    • Re: mysql_real_query and escaping a semicolonPaul DuBois29 Apr
  • Re: mysql_real_query and escaping a semicolonAnna Fowles-Winkler29 Apr
    • Re: mysql_real_query and escaping a semicolonMichael Widenius30 Apr