6 Replies - 4027 Views - Last Post: 08 February 2013 - 04:12 PM Rate Topic: -----

#1 nazirul_137  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 15
  • Joined: 06-February 13

Insert data into oracle table using PHP

Posted 06 February 2013 - 07:44 PM

Anybody can tell me how to write the code for insert data into oracle table using PHP? i have no experience using oracle database in PHP.
Is This A Good Question/Topic? 0
  • +

Replies To: Insert data into oracle table using PHP

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,441
  • Joined: 08-June 10

Re: Insert data into oracle table using PHP

Posted 07 February 2013 - 12:31 AM

the PHP Manual has a section about Oracle DB functions and there is also an OCI driver for PDO.
Was This Post Helpful? 1
  • +
  • -

#3 nazirul_137  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 15
  • Joined: 06-February 13

Re: Insert data into oracle table using PHP

Posted 08 February 2013 - 01:32 AM

This is my code for insert1:

<form action="insert2.php" name="frmAdd" method="POST">
<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">Businesses ID </div></th>
    <th width="160"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Address</div></th>
    <th width="97"> <div align="center">City</div></th>
    <th width="70"> <div align="center">Telephone</div></th>
    <th width="70"> <div align="center">URL</div></th>
  </tr>
  <tr>
    <td><div align="center"><input name="txtBusinessesID" type="text" size="20" maxlength="50" id="txtBusinessesID">
    </div></td>
    <td><input name="txtName" type="text" size="20" maxlength="50"></td>
    <td><input name="txtAddress" type="text" size="20" maxlength="50" id="txtAddress"></td>
    <td><div align="center"><input name="txtCity" type="text" size="20" maxlength="50" id="txtCity">
    </div></td>
    <td align="right"><input name="txtTelephone" type="text" size="20" maxlength="50" id="txtTelephone"></td>
    <td align="right"><input name="txtURL" type="text" size="20" maxlength="50" id="txtURL"></td>
  </tr>
</table>
<input type="submit" name="submit" value="submit">
</form>


Insert 2:

<?
//*** Connection to Oracle ***//
$conn = oci_connect("asd", "asd", "asd");

//*** Insert Data Command ***//
$strSQL = "INSERT INTO X_BUSINESSES ";
$strSQL .="(BUSINESS_ID,NAME,ADDRESS,CITY,TELEPHONE,URL) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtBusinessesID"]."','".$_POST["txtName"]."','".$_POST["txtAddress"]."' ";
$strSQL .=",'".$_POST["txtCity"]."','".$_POST["txtTelephone"]."','".$_POST["txtURL"]."') ";

//*** Define Variable $objParse and $objExecute ***//
$objParse = oci_parse($conn, $strSQL);
$objExecute = oci_execute($objParse, OCI_DEFAULT);
if($objExecute)
{
	oci_commit($conn); //*** Commit Transaction ***//
	echo "Save completed.";
}
else
{
	oci_rollback($conn); //*** RollBack Transaction ***//
	$m = oci_error($objParse); 
	echo "Error Save [".$m['message']."]";
}

//*** Close Connection to Oracle ***//
oci_close($conn);
?>


When i submit the data, its not work. Anybody can help me to solve this problem.

This post has been edited by Dormilich: 08 February 2013 - 02:06 AM
Reason for edit:: please use [code] [/code] tags when posting code

Was This Post Helpful? 0
  • +
  • -

#4 laytonsdad  Icon User is offline

  • Cheese and Sprinkles
  • member icon

Reputation: 446
  • View blog
  • Posts: 1,921
  • Joined: 30-April 10

Re: Insert data into oracle table using PHP

Posted 08 February 2013 - 01:04 PM

What errors are you getting? What is/not happening?
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3806
  • View blog
  • Posts: 13,499
  • Joined: 12-December 12

Re: Insert data into oracle table using PHP

Posted 08 February 2013 - 01:30 PM

Your opening PHP tag is incomplete: <? should be <?php.

This post has been edited by andrewsw: 08 February 2013 - 01:30 PM

Was This Post Helpful? 1
  • +
  • -

#6 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: Insert data into oracle table using PHP

Posted 08 February 2013 - 03:58 PM

View Postandrewsw, on 08 February 2013 - 08:30 PM, said:

Your opening PHP tag is incomplete: <? should be <?php.

That's not always the case though. With the short-open-tag directive enabled in the config, the <? version of the tag can be used.

Not that I'd recommend people use the short tags. It's far less troublesome to use the full <?php tag.
Was This Post Helpful? 2
  • +
  • -

#7 andrewsw  Icon User is offline

  • It's just been revoked!
  • member icon

Reputation: 3806
  • View blog
  • Posts: 13,499
  • Joined: 12-December 12

Re: Insert data into oracle table using PHP

Posted 08 February 2013 - 04:12 PM

View PostAtli, on 08 February 2013 - 03:58 PM, said:

Not that I'd recommend people use the short tags. It's far less troublesome to use the full <?php tag.

Thank you.
I agree, I always use the full tag.

@Atli and thank you for my 100 :) :bananaman:

This post has been edited by andrewsw: 08 February 2013 - 04:14 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1