Jump to content

Insert Image Into Database


Recommended Posts

I've got a PeopleSoft DB that I'm pulling images from with a PHP script using OCI. I am able to pull images and save them to .jpg files and everything works fine. When I try and insert a new image into the DB I am having issues. Here is what I'm doing.


Reading *.jpg to a file call $img[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$img = fread(fopen(\'pic.jpg\', \'r\'), filesize(\'pic.jpg\'));[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]


Putting query together [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$sql = \"INSERT INTO PS_PROD_IMAGES     (SETID,    PRODUCT_ID,    IMAGE_SIZE,    DESCR, PSIMAGEVER, ROW_ADDED_DTTM, ROW_ADDED_OPRID,    ROW_LASTMANT_DTTM, ROW_LASTMANT_OPRID,     SYNCID, SYNCDTTM, PROD_IMG_JPG)    VALUES    (\'SHARE\', \'15001\', \'L\', \' \', \'\".$mxi++.\"\', SYSDATE, \'SMELBAN\',      SYSDATE, \'SMELBAN\', \'0\', SYSDATE, \'\".$img.\"\')\";[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]


Running query[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]$c=OCILogon($db[\'user\'], $db[\'pass\'], $db[\'db\']);

$s = OCIParse($c, $sql);



And then here is what I get

Successfully connected to Oracle.

Warning: ociparse() [function.ociparse]: OCIParse: ORA-00972: identifier is too long in e:\wamp\www\norwood.com_tools\update 06 images\index.php on line 50

Warning: ociexecute(): supplied argument is not a valid OCI8-Statement resource in e:\wamp\www\norwood.com_tools\update 06 images\index.php on line 51


My image file is 3.89kb large. I've also tried with a smaller 2.31kb file.

Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.