Bluehost.com Web Hosting $6.95

newbie: Unknown column 'image' in 'field list'

This is a discussion on newbie: Unknown column 'image' in 'field list' within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hey This php (version 5.20) code: $sql = "insert into Picture(Property, Mime, Data) values (1 , $type, \"".$...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-27-2007
Jeff
 
Posts: n/a
Default newbie: Unknown column 'image' in 'field list'

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!

Jeff



Reply With Quote
  #2 (permalink)  
Old 01-27-2007
Rik
 
Posts: n/a
Default Re: newbie: Unknown column 'image' in 'field list'

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
Reply With Quote
  #3 (permalink)  
Old 01-27-2007
Jeff
 
Posts: n/a
Default Re: newbie: Unknown column 'image' in 'field list'


"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

Here is the echo of $sql:
insert into Picture(Property, Mime, Data) values (1 , image/pjpeg,
"????\0JFIF\0\0\0d\0d\0\0??\0Ducky\0\0\0\0\0 F\0\0??\0Adobe\0d?\0\0\0??\0?\0 
  P???")Unknown column 'image' in 'field list'

From $sql above I removed many characthers... it was very very many special
characters like  wich I removed in this post to make it more readable

Any suggestions?

Jeff


Reply With Quote
  #4 (permalink)  
Old 01-27-2007
Jeff
 
Posts: n/a
Default Okay, I think I've solved it

"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();
}


Reply With Quote
  #5 (permalink)  
Old 01-27-2007
Norman Peelman
 
Posts: n/a
Default Re: Okay, I think I've solved it

Jeff wrote:
> "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...


Jeff,

This is what I do:

$allowedtypes =
array('image/jpg','image/jpeg','image/pjpeg','image/gif','image/png','image/x-png');
if (in_array($_FILES["file_$choice"]['type'], $allowedtypes))
{
// we have an image file - that's all we want.
// good upload - process file (store in database)
$upload =
str_replace('\\','\\\\',$_FILES["file_$choice"]['tmp_name']);
$atype = $_FILES["file_$choice"]['type'];
$aname = $_FILES["file_$choice"]['name'];
$asize = $_FILES["file_$choice"]['size'];

$query = "INSERT INTO picture SET Property = 1, Mime = $atype, Data
= LOAD_FILE('$upload')";
$result = mysql_query($query,$dbc);
}
---

Now this is a really hacked excerpt from my code but you should get the
idea. There are alot of other things to check for (filesize != 0, etc.

Norm

Reply With Quote
  #6 (permalink)  
Old 01-28-2007
Michael Fesser
 
Posts: n/a
Default Re: newbie: Unknown column 'image' in 'field list'

..oO(Jeff)

>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'


$sql = "
INSERT INTO Picture (Property, Mime, Data)
VALUES (1, '$type', '$image')";

Watch the quoting when inserting strings.

Micha
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:29 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0