/*
create table images
{
image_id int not null primary key,
image_data blob
}
*/
int load_image(MYSQL *conn, int id, FILE *f)
{
char query[1024*100], buf[1024*10], *p;
unsigned int from_len;
int status;sprintf(query,"insert into image values(%d,'",id);
p=query+strlen(query);
while()
{
/*don't overrun end of query buffer!*/
if (p +(2*from_len) + 3 > query + sizeof (query))
{
print_error(NULL, "image too big");
return(1);
}
p += mysql_escape_string (p, buf, from_len);
}
(void) strcpy(p, "')");
status = mysql_query (conn, query);
return (status);
}