Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][Oracle] - problem z blob-em
Okto
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 11.12.2010

Ostrzeżenie: (0%)
-----


Witam,
chciałem skorzystać z trywialnej stronki za pomocą której mógłbym ładować zdjęcia do bazy oracle i niestety się nie udaje poniżej kod i dwa błędy no i prośba o pomoc :


  1.  
  2. // filename: uploadimage3-form.php
  3.  
  4. <HEAD><TITLE>Store binary data into SQL Database</TITLE></HEAD>
  5.  
  6. <form method="post" action="uploadimage3.php" enctype="multipart/form-data">
  7. File Description:<br>
  8. <input type="text" name="id" size="40">
  9. <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
  10. <br>File to upload/store in database:<br>
  11. <input type="file" name="file_data" size="40">
  12. <p><input type="submit" name="submit" value="submit">
  13. </form>
  14.  
  15. </BODY>
  16. </HTML>




  1. <?php
  2.  
  3. // filename: uploadimage3.php
  4.  
  5. $username = 'CRI';
  6. $password = 'CRI';
  7. $dbname = 'IP/CBI';
  8.  
  9.  
  10.  
  11. echo $_POST['submit'];
  12.  
  13. if(array_key_exists('submit',$_POST))
  14. {
  15.  
  16. echo "tmp_name : ".$tmpfilename = $_FILES['file_data']['tmp_name'];
  17. print "<br>\n\t";
  18. echo "filesize : ".$filesize = filesize($tmpfilename);
  19. print "<br>\n\t";
  20. echo "filetype : ".$filetype = $_FILES['file_data']['type'];
  21. print "<br>\n\t";
  22. echo "filename : ".$filename = $_FILES['file_data']['name'];
  23. print "<br>\n\t";
  24. //echo "descript : ".$file_description = $_POST['file_description'];
  25. //print "<br>\n\t";
  26. echo "id : ".$id = $_POST['id'];
  27. print "<br>\n\t";
  28.  
  29. $data = addslashes(fread(fopen($tmpfilename, "r"), $filesize));
  30. //$data = (fread(fopen($form_data, "r"), filesize($form_data)));
  31. //You have to pass Appropriate username, Password,Serveice name
  32. $db = OCILogon($username, $password, $dbname);
  33.  
  34.  
  35.  
  36. $stmt = OCIParse($db,"INSERT INTO BLOB_TABLE VALUES($id,EMPTY_BLOB()) returning id,IMG into :id,:lob");
  37. $lob = OCINewDescriptor($db);
  38. OCIBindByName($stmt,":ID",$id,32);
  39. OCIBindByName($stmt,":LOB",$lob,-1,SQLT_BLOB);
  40. // we cannot use autocommitt here
  41. $exec_result=OCIExecute($stmt,OCI_DEFAULT);
  42. $lob->save($data);
  43. //echo "$form_data id:$id\n";
  44. OCICommit($db);
  45. if(!$exec_result)
  46. {
  47. print "Error Occured".OCIError($db);
  48. }else{
  49. OCICommit ($db);
  50. print "<p>This file has been uploaded into Database ";
  51. }
  52. }
  53. ?>




PHP Warning: ociexecute() [<a href='function.ociexecute'>function.ociexecute</a>]: ORA-00904: &quot;IMG&quot;: niepoprawny identyfikator in uploadimage3.php on line 36
PHP Warning: OCI-Lob::save() [<a href='oci-lob.save'>oci-lob.save</a>]: OCI_INVALID_HANDLE in uploadimage3.php on line 37






No i nie wstawia.

PHP 5.3.3; Oracle 11g; oci8 version: 1.4.1

Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 21:52