Sorry to suggest this but is it just possible that the 'data' object you are
doing a strlen on is not null terminated or in fact contains earlier null
characters which are terminating your effort.  I have made this mistake several
times when using mysql_escape_string.  Now to avoid it I just use pointer
arithmetic.

Seth Northrop wrote:

> >
> > You are possibly not escaping binary fields. You should use
> > mysql_escape_string() function on binary objects prior to inserting it
> > in the INSERT command, or use load_file() function.
> >
>
> Thanks Sinisa for the reply!
>
> There really isn't any binary data.. and, we are calling
> mysql_escape_string.. here is the snippet of code:
>
> // START SNIP
>
>     int state;
>     unsigned int encoded_str_length = 0;
>     MYSQL_RES *result;
>     MYSQL_ROW row;
>     char *sql, *escaped_data;
>     escaped_data = new char[2*strlen(data)+1]; //required by mysql
>     sql = new char[2*strlen(data)+600];// +1
>
>     encoded_str_length = mysql_escape_string(escaped_data,data,strlen(data));
>
>     sprintf(sql,"%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%d%s%s%s",
>        "REPLACE into reflectivity.measurement_extended_data set
>                 content_typeID = ",content_typeID,
>                 ", contentID = ",contentID,
>                 ", arrayID = ",arrayID,
>                 ", positionID = ",positionID,
>                 ", testID = ",testID,
>                 ", iteration = ",iteration,
>                 ", test_locationID = ",test_locationID,
>                 ", date_added = ",date_added,
>                 ", added_by = ",added_by,
>                 ", data = '",escaped_data,"'");
>
>     state = mysql_query(connection,sql);
>
>     delete [ ] sql;
>     delete [ ] escaped_data;
>
>     if (state != 0)
>     {
>
>       Application->MessageBox(mysql_error(connection),NULL,MB_OK);
>       return 0;
>     }
>
> // END SNIP
>
> And, as I mentioned, if I do something like:
>
> bin/mysql <-u & -p> <database> < foo.sql
>
> where foo.sql contains the query checked for sanity the exact same result
> occurs.
>
> ---------------------------------------------------------------------
> 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 <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to