You are here: Re: Okay, I think I've solved it « PHP Language « IT news, forums, messages
Re: Okay, I think I've solved it

Posted by Norman Peelman on 01/27/07 12:35

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация