我试图将一些数据输入甲骨文表中,并接收错误代码ORA-01722。我相信这是因为Trader ID,它是一个数字,但它说它不能将字符串转换为数字。下面的代码。
表格
<form method="post" action="recipesql.php" >
<table align="center">
<tr>
<td align="right">Recipe Name:</td>
<td align="left"><input type="text" name="RecipeName"></td>
</tr>
<tr>
<td align="right">Media Type:</td>
<td align="left"><input type="text" name="MediaType"></td>
</tr>
<tr>
<td align="right">Recipe:</td>
<td align="left"><input type="text" name="Recipe" /></td>
</tr>
<tr>
<td align="right">Video Link (e.g /embed/12345):</td>
<td align="left"><input type="text" name="Link"></td>
</tr>
<tr>
<td align="right">Trader ID:</td>
<td align="left"><input type="number" name="TraderID"></td>
</tr>
</table>
<input type="submit" value="Submit" name="Submit">
</form>PHP
//include connection
include ('PHP/connection.php');
//has form been submitted?
if(isset($_POST['Submit'])){
$RecipeName=$_POST['Name'];
$MediaType=$_POST['MediaType'];
$Recipe=$_POST['Recipe'];
$Link=$_POST['Video_Link'];
$TraderID=$_POST['Trader_ID'];
//Insert data
$query = "INSERT INTO MEDIA
(Media_Id, Name, MediaType, Recipe, Video_Link, Trader_ID)
VALUES
('MEDIA_seq.nextval','$RecipeName','$MediaType','$Recipe','$Link','$TraderID')";
$runquery = oci_parse($connection,$query);
oci_execute($runquery);
}
//to check if the if statement is working
else
{
echo "Error";
}错误代码警告: oci_execute() function.oci-execute: ORA-01722:第19行recipesql.php中的无效编号
发布于 2015-05-03 19:24:48
认为应该是:
$query = "INSERT INTO MEDIA (Media_Id, Name, MediaType, Recipe, Video_Link, Trader_ID)
VALUES (MEDIA_seq.nextval,'$RecipeName','$MediaType','$Recipe','$Link','$TraderID')";即MEDIA_seq.nextval不包含在''中。否则,它将被解释为VARCHAR2,并将其插入到NUMBER列中将导致ORA-01722。
https://stackoverflow.com/questions/30018293
复制相似问题