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.
Insert data into oracle table using PHP
Page 1 of 16 Replies - 296 Views - Last Post: 08 February 2013 - 04:12 PM
Replies To: Insert data into oracle table using PHP
#2
Re: Insert data into oracle table using PHP
Posted 07 February 2013 - 12:31 AM
#3
Re: Insert data into oracle table using PHP
Posted 08 February 2013 - 01:32 AM
This is my code for insert1:
Insert 2:
When i submit the data, its not work. Anybody can help me to solve this problem.
<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
#4
Re: Insert data into oracle table using PHP
Posted 08 February 2013 - 01:04 PM
What errors are you getting? What is/not happening?
#5
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
#6
Re: Insert data into oracle table using PHP
Posted 08 February 2013 - 03:58 PM
andrewsw, 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.
#7
Re: Insert data into oracle table using PHP
Posted 08 February 2013 - 04:12 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|