Jump to content

Insert Image Into Database


melban

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);

OCIExecute($s);[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

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 comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.