Solved

Use php script to insert into oracle database

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

813 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