Jump to content

kkiboo

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Everything posted by kkiboo

  1. I tested this sample code and everything is fine to upload and display a BLOB. <?php // // Sample form to upload and insert an image into an ORACLE BLOB // column using PHP 5's OCI8 API. // // Note: Uses the new PHP 5 names for OCI8 functions. // // Before running this script, execute these statements in SQL*Plus: // drop table btab; // create table btab (blobid number, blobdata blob); // // This example uploads an image file and inserts it into a BLOB // column. The image is retrieved back from the column and displayed. // Make sure there is no whitespace before "<?php" else the wrong HTTP // header will be sent and the image won't display properly. // // Make sure php.ini's value for upload_max_filesize is large enough // for the largest lob to be uploaded. // // Tested with Zend Core for Oracle 1.3 (i.e. PHP 5.0.5) with Oracle 10.2 // // Based on a sample originally found in // http://www.php.net/manual/en/function.ocinewdescriptor.php // $myblobid = 1; // should really be a unique id e.g. a sequence number define("ORA_CON_UN", "user1"); // username define("ORA_CON_PW", "password1"); // password define("ORA_CON_DB", "dbname"); // connection string if (!isset($_FILES['lob_upload'])) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> Image filename: <input type="file" name="lob_upload"> <input type="submit" value="Upload"> </form> <?php } else { $conn = oci_connect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB); // Delete any existing BLOB so the query at the bottom // displays the new data $query = 'DELETE FROM BTAB WHERE BLOBID = :MYBLOBID'; $stmt = oci_parse ($conn, $query); oci_bind_by_name($stmt, ':MYBLOBID', $myblobid); $e = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS); if (!$e) { die; } oci_free_statement($stmt); // Insert the BLOB from PHP's tempory upload area $lob = oci_new_descriptor($conn, OCI_D_LOB); $stmt = oci_parse($conn, 'INSERT INTO BTAB (BLOBID, BLOBDATA) ' .'VALUES(:MYBLOBID, EMPTY_BLOB()) RETURNING BLOBDATA INTO :BLOBDATA'); oci_bind_by_name($stmt, ':MYBLOBID', $myblobid); oci_bind_by_name($stmt, ':BLOBDATA', $lob, -1, OCI_B_BLOB); oci_execute($stmt, OCI_DEFAULT); // The function $lob->savefile(...) reads from the uploaded file. // If the data was already in a PHP variable $myv, the // $lob->save($myv) function could be used instead. if ($lob->savefile($_FILES['lob_upload']['tmp_name'])) { oci_commit($conn); } else { echo "Couldn't upload Blob\n"; } $lob->free(); oci_free_statement($stmt); // Now query the uploaded BLOB and display it $query = 'SELECT BLOBDATA FROM BTAB WHERE BLOBID = :MYBLOBID'; $stmt = oci_parse ($conn, $query); oci_bind_by_name($stmt, ':MYBLOBID', $myblobid); oci_execute($stmt, OCI_DEFAULT); $arr = oci_fetch_assoc($stmt); $result = $arr['BLOBDATA']->load(); // If any text (or whitespace!) is printed before this header is sent, // the text won't be displayed and the image won't display properly. // Comment out this line to see the text and debug such a problem. header("Content-type: image/JPEG"); echo $result; oci_free_statement($stmt); oci_close($conn); // log off } ?> But what I would like to do now is have 2 seperate pages: One that uploads an image into the BLOB column for a specific row (already created; it is a table for Employee data. Employee ID, Pic, Name) and then gives a confirmation, and another page that queries the entire Employee data table and displays all the columns. The above code only allows for one upload and one display. What steps would I take in order to accomplish this? For the latter page, I assume the query would be: $query = 'SELECT * FROM BTAB'; But, do I still have to do special stuff to view the images properly? Or will that return just fine after blobs are uploaded? Thanks in advance for any replies.
  2. Hey all, I am trying to make it to where when the Log Out link is clicked, it logs the user out, closes the popup window (where the link is) and redirects the parent window to the login page. Here are my codes right now: The logout function (defined in the login script): if(@$_POST["a"]=="logout" || @$_GET["a"]=="logout") { if($auditObj) $auditObj->LogLogout(); session_unset(); setcookie("username","",time()-365*1440*60); setcookie("password","",time()-365*1440*60); header("Location: login.php"); exit(); } The logout link (found in the popup window page): <A class=tablelinks href="login.php?a=logout">Log out</A> The javascript for the popup window, found in the parent window page: <script language="JavaScript"> <!-- function Window() { window.open("popup.php", "Window", "menubar=no,width=1200,height=550,toolbar=no, resizeable=yes, scrollbars=yes"); } Would it be a matter of inserting the echo "<script....."; to put the close window function inside the PHP logout link code? I'm not sure what the best way to do it is, or if it will even work. Thanks for any help.
  3. Soooo I'm tearing my hair out. I am just trying to make a switch that, after a successful login, it checks for the userlevel of the user, passes it to a switch and based on the case, redirects to their respective page. Database is Oracle 11g, I am using PHPRunner. This is the script for the event that happens after a successful login: <?php // After successful login function AfterSuccessfulLogin($username,$password,&$data) {$sql="select userlevel from LOGIN where USERNAME='".$_SESSION["UserID"]."'"; $rs = CustomQuery($sql); if($data=db_fetch_array($rs)){ switch($data["userlevel"]){ case "admin": header("Location: AUDIT_TABLE_list.php"); break; case "redauditor": header("Location: test2.php"); break; default: header("Location: main.php"); // redirect to main page if no permission is set break; } } ; } // function AfterSuccessfulLogin ?> So, the login (not showed) goes through but when it executes this it ONLY redirects to the first case specified. (In the code above: AUDIT_TABLE_list.php). If I change the cases to numbers (and equivalently change the datatype on the column to number as well) I get the same problem. If I quote the numbers, it displays the default page. What's going wrong? How can I get it to recognize the other cases? Should I just start from scratch and make the switch without using the PHPRunner variables - if so, what does this look like for Oracle? (I know how to do it for mysql) m._.m Any help is appreciated, thank you.
  4. Forgive me if this is a newbie question. All the data I am trying to display is numeric, but to display it to the users, I want it to be displayed as something else. Here is an example. My TEAM table, the column TEAM NAME, the first row value is 1. I want the user to see 'Pink Team' instead of 1. But I want all the data on the backend to still be numeric. How do I do this? Aliases? Casting? Help!
  5. Hello all, I'm having some trouble here: I'd like to create a series of charts based on different data sets from the same table. The problem is, most of the columns are not numeric. I have fields such as: Team, Employee, Grade, etc. Is there any good way to chart this data as in (varchar2) or do I HAVE to somehow make it numeric? If so, is there an easier way to do this via aliases perhaps? Charts are driving me mad.
  6. I apologize in advance if this has been covered before, I searched, I promise! I am building a web application using Oracle for the backend. I am looking for a way to use PHP to basically log a user in (this is the easy part) and upon logging in, check their profile and then display a custom/unique "home" page for them. Kind of like when you log into eBay and you can go to myeBay, or w/e. Basically, I have 20 or so users who, upon logging in, need information from the database that is relevant to their specific role displayed in front of them. I am not a complete PHP newbie, but this one is stumping me. Any pointers?
×
×
  • 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.