oci_execute():ORA-00001:第10行E:\ Xamp \ htdocs \ show.php中违反了唯一约束(SYSTEM.SYS_C0010278)
当我使用select *检查sql plus时,没有选择行
<?php // File: anyco.php
require('anyco_ui.inc.php');
// Create a database connection
$conn = oci_connect('system','123','localhost/orcl');
ui_print_header('Employees');
$q= "insert into Employee values(1005099,'NawSafrin','Sattar','female','Mohammadpur',01520100508,'Senior',15000,'8 AM-5 PM','1-Jan-2011')";
$s = oci_parse($conn,$q);
$r1= oci_execute($s,OCI_DEFAULT);
do_query($conn, "SELECT * FROM Employee");
ui_print_footer(date('Y-m-d H:i:s'));
// Execute query and display results
function do_query($conn, $query)
{
$stid = oci_parse($conn, $query);
$r = oci_execute($stid, OCI_DEFAULT);
print '<table border="1">';
print '<tr>';
print '<td>Employee ID<td>Employee Fname<td>Employee Lname<td>gender<td>address<td>phn_Number<td>category<td>salary<td>work_hr<td>join_date';
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS))
{
print '<tr>';
foreach ($row as $item)
{
print '<td>'.
($item!== null ? htmlentities($item) : ' ').'</td>';
}
print '</tr>';
}
print '</table>';
}
?>
答案 0 :(得分:1)
这里的mysql语法不正确:
$q= "insert into Employee values(1005099,'NawSafrin','Sattar','female','Mohammadpur',01520100508,'Senior',15000,'8 AM-5 PM','1-Jan-2011')";
必须:
$q= "insert into Employee('name of all columns you like to be inserted') values(1005099,'NawSafrin','Sattar','female','Mohammadpur',01520100508,'Senior',15000,'8 AM-5 PM','1-Jan-2011')";