Solved

Use php script to insert into oracle database

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.  …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

914 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

12 Experts available now in Live!

Get 1:1 Help Now