Solved

Use php script to insert into oracle database

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
htaccess block all countries but the US 4 91
Convert php array to comma seperated list 19 50
php output utf-8 problem 6 46
Undefined variable with $_POST in PHP 5 31
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.  …
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

738 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