MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Dave Beck Date:July 2 2002 8:55pm
Subject:Re: mysql_real_query, insert floats as binary
View as plain text  
> ...and some bytes may represent an 'illegal' character, and thus must be
> escaped by a backslash... this goes for the quote character you use (" or
> '), the backslash character itself, and null bytes.

Thanks, if I use mysql_real_query is this still the case?

--
David A. C. Beck
dacb@stripped
Valerie Daggett Laboratory
Biomolecular Structure and Design Program
Department of Medicinal Chemistry
University of Washington, Seattle


On Tue, 2 Jul 2002, Roger Baklund wrote:

> * Dave Beck
> [...]
> > > char	insert_format[] = "INSERT INTO %s VALUES (%hhd%hhd%hhd%hhd,
> > > %hhd%hhd%hhd%hhd, %hhd%hhd%hhd%hhd, %hhd%hhd%hhd%hhd,%hhd%hhd%hhd%hhd)";
> 
> The values should be quoted...
> 
> > > int build_real_insert(char *query, char *table, int frame, int
> > atom, float
> > > x, float y, float z) {
> > > 	unsigned char	*fbp = (unsigned char *)&frame;
> > > 	unsigned char	*abp = (unsigned char *)&atom;
> > > 	unsigned char	*xbp = (unsigned char *)&x;
> > > 	unsigned char	*ybp = (unsigned char *)&y;
> > > 	unsigned char	*zbp = (unsigned char *)&z;
> > >
> > > 	return sprintf(query, insert_format, table, fbp[0], fbp[1],
> > > fbp[2], fbp[3], abp[0], abp[1], abp[2], abp[3], xbp[0], xbp[1], xbp[2],
> > > xbp[3], ybp[0], ybp[1], ybp[2], ybp[3], zbp[0], zbp[1], zbp[2], zbp[3]);
> > > }
> 
> ...and some bytes may represent an 'illegal' character, and thus must be
> escaped by a backslash... this goes for the quote character you use (" or
> '), the backslash character itself, and null bytes.
> 
> --
> Roger
> sql
> 

Thread
mysql_real_query, insert floats as binaryDave Beck27 Jun
  • Re: mysql_real_query, insert floats as binaryDave Beck2 Jul
    • Re: mysql_real_query, insert floats as binaryRoger Baklund2 Jul
      • Re: mysql_real_query, insert floats as binaryDave Beck2 Jul
        • Re: mysql_real_query, insert floats as binaryRoger Baklund2 Jul