|
Posted by Jeff on 01/27/07 05:12
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.tmseqrmtqnv3q9@misant.kabel.utwente.nl...
Jeff <it_consultant1@hotmail.com.NOSPAM> wrote:
> Hey
>
> This php (version 5.20) code:
> $sql = "insert into Picture(Property, Mime, Data) values (1 , $type,
> \"".$image."\")";
>
> Generate this sql (MySql5) error:
> Unknown column 'image' in 'field list'
>
> Any suggestions on how to solve this are very welcome!
Euhm, echo $sql if you please...
--
Rik Wasmus
I post my code below just in case somebody else needs it.... I'm happy to
share :-)
This code works, but I'm a newbie so maybe you see some potential problems
with my code... for example now I didn't use any "\"" for to include the
$image... I simply used '$image'... may this cause problem???.. I haven't
had any problems yet.. I just ask just in case....
I replaced my original code with this code:
if ($_FILES['userfile']['size'] > 0) {
$type = $_FILES['userfile']['type'];
$instr = fopen($_FILES['userfile']['tmp_name'], "r");
$image = fread($instr, $_FILES['userfile']['size']);
$image = addslashes($image);
fclose($instr);
@ $db = new mysqli('localhost', 'xxxxxr', 'xxxxxxxx',
'fffffff4ffffffffffffff');
$sql = "insert into Picture(Property, Mime, Data) values (57, '$type',
'$image')"; //57 is just test data, will be replaced my a variable
$result = $db->query($sql);
if (mysqli_errno($db)) {
echo mysqli_error($db);
} else {
echo "OKAY";
}
$db->close();
}
[Back to original message]
|