Solved

Use php script to insert into oracle database

Posted on 2003-11-02
3
268 Views
Last Modified: 2013-12-12
 Hallo
   I am supposed to insert data into a Oracle 8i database using php.  The thing is am I not sure how i am supposed to do that.  I am supposed to make php script upload it to a server at the university go into oracle using sqlplus and somehow execute it from there..
 I made a test script
<table border="1" cellpadding="3">
<tr>
  <td><b>Name</b></td>
  <td><b>Preis</b></td>
</tr>
<?
  $connection = OCILogon("a6666666", "test1234");
  $stmt = OCIParse($connection, "SELECT * FROM Kebab ORDER BY Name ASC");
  OCIExecute($stmt);

  while(OCIFetch($stmt))
  {
    print "<tr>\n";
    print "  <td>" . OCIResult($stmt, "NAME") . "  </td>\n";
    print "  <td>" . OCIResult($stmt, "PREIS") . "  </td>\n";
    print "</tr>\n";
  }

  OCIFreeStatement($stmt);
  OCILogoff($connection);
?>
</table>

using this table:


DROP TABLE Kebab;

CREATE TABLE Kebab (
  Name CHAR(25),
  Preis NUMBER(3,2)
);

INSERT INTO Kebab VALUES ('Doener', 2.50);
INSERT INTO Kebab VALUES ('Iskender', 4.20);

COMMIT;

The thing I dont understand ist how am I supposed to save the php file...as .php   .txt or .sql
  while evertime I try to execute in in sqlplus  (using @filename.??? I always become so many "unknknown command" lines
0
Comment
Question by:va80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:va80
ID: 9665700
Please someone help me need this ASAP!!!
0
 
LVL 14

Expert Comment

by:ThG
ID: 9667474

Sorry I don't understand your problem. Why don't you call it from the http server?
0
 
LVL 1

Accepted Solution

by:
helloAmerica earned 500 total points
ID: 9674619
true.

The PHP file ("script") works only "in" a webserver (or fromthe command line in CLI mode). What you wrote should work (althought I would have tested OCIexecute() results :D ) but requires you to run your script like this :

http://localhost/somepath/yourscript.php
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question