Solved

Use php script to insert into oracle database

Posted on 2003-11-02
3
263 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
3 Comments
 

Author Comment

by:va80
Comment Utility
Please someone help me need this ASAP!!!
0
 
LVL 14

Expert Comment

by:ThG
Comment Utility

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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now