doulong4169 2014-04-09 17:49
浏览 29

在php中插入mysql时出错

<?php
if (isset($_POST['submitted'])){
include('connect.php');
$name=$_POST['name'];
$addr=$_POST['addr'];
$phno=$_POST['phno'];
$tr=$_POST['tr'];
$trd=$_POST['trd'];
$sname=$_POST['sname'];
$sphno=$_POST['sphno'];
$sfield=$_POST['sfield'];
$med=$_POST['med'];
$apaid=$_POST['apaid'];
$apend=$_POST['apend'];

$sqlinsert="INSERT INTO patient (name , addr , phno , tname , tdate , sName , sphno , sSpeciality , med , amtpaid , amtrem) VALUES 
('$name','$addr','$phno','$tr','$trd','$sname','$sphno','$sfield','$med','$apaid','$apend')";

if(!mysql_query($dbcon , $sqlinsert))
{
        die('error inserting new record');
}
else
echo "new";
}
?>

<html>
<head>
    <title>Insert Data</title>
</head>
<body>
<h1>Insert Data</h1>
<form method="post" action="insert.php">
<input type="hidden" name="submitted" value="true" />
<fieldset>
<legend>New Patient</legend>
<label>Name : <input type="text" name="name" /></label>
<label>Address : <input type="text" name="addr" /></label>
<label>Phone no : <input type="text" name="phno" /></label>
<label>Treatment : <input type="text" name="tr" /></label>
<label>Treatment date : <input type="text" name="trd" /></label>
<label>Specialist Recommended : <input type="text" name="sname" /></label>
<label>Specialist phno : <input type="text" name="sphno" /></label>
<label>Specialist field : <input type="text" name="sfield" /></label>
<label>Medicine : <input type="text" name="med" /></label>
<label>Amount Paid : <input type="text" name="apaid" /></label>
<label>Amount Pending : <input type="text" name="apend" /></label>
</fieldset>
<br />
<input type="submit"value="add new record" />
</form>
</body>
</html>

i m getting this error while inserting even when the table has a string variable

Warning: mysql_query() expects parameter 1 to be string, object given in C:\xampp\htdocs\insert.php on line 18 error inserting new record

please help...

  • 写回答

3条回答 默认 最新

  • duanpi5733 2014-04-09 17:51
    关注

    Read the docs:

    mixed mysql_query ( string $query [, resource $link_identifier = NULL ] )

    Side point:

    There is no more support for mysql_* functions, they are officially deprecated, no longer maintained and will be removed in the future. You should update your code with PDO or MySQLi to ensure the functionality of your project in the future.

    评论

报告相同问题?

悬赏问题

  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线