- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将我的 PHP 代码更改为另一个安全代码,因此我更改了 update.PHP 页面 from this对此:
<?php
require_once ('../include/global.php');
$id=$_REQUEST['id'];
if (isset ($_POST['name'])) {
$name = $_POST['name'];
}
if (isset ($_POST['remarcs'])) {
$remarcs = $_POST['remarcs'];
}
if (isset ($_POST['test_res'])) {
$test_res = $_POST['test_res'];
}
if (isset ($_POST['address'])) {
$address = $_POST['address'];
}
if (isset ($_POST['date'])) {
$date = $_POST['date'];
}
if (isset ($_POST['phone_num'])) {
$phone = $_POST['phone_num'];
}
if (isset ($_POST['illness'])) {
$illness = $_POST['illness'];
}
if (isset ($_POST['echo'])) {
$echo = $_POST['echo'];
}
if (isset ($_POST['pe'])) {
$pe = $_POST['pe'];
}
if (isset ($_POST['pmhx'])) {
$pmhx = $_POST['pmhx'];
}
if (isset ($_POST['pshx'])) {
$pshx = $_POST['pshx'];
}
if (isset ($_POST['habbits'])) {
$habbits = $_POST['habbits'];
}
if (isset ($_POST['occup'])) {
$occup = $_POST['occup'];
}
if (isset ($_POST['allergy'])) {
$allergy = $_POST['allergy'];
}
//Check file is uploaded or not
//if (isset($_FILES['file']['name']) && $_FILES['file']['name']!='' && $_FILES['file']['error']=='') {
//$path2 = ... ;
//move_uploaded_file(...);
if(is_uploaded_file($_FILES["file"]["tmp_name"]))
{
$path = "../uploads/".$_FILES['file']['name'];
move_uploaded_file($_FILES["file"]["tmp_name"], $path);
$new_path = "./uploads/".$path;
}
else{
$new_path = $_POST['org_path'];
//$path2 = "../uploads/".$_FILES['echo_photo']['name'];
}
$sql=('UPDATE $tbl_name SET name = ?,
echo_files = ?,
remarcs = ?,
test_res = ?,
date = ?,
address = ?,
phone_num = ?,
illness = ?,
echo = ?,
pmhx = ?,
pshx = ?,
habbits = ?,
occup = ?,
allergy = ?,
pe = ?
WHERE id = ? ');
$stmt= $con->prepare($sql);
$stmt->bind_param("ssssssssssssssi", $name, $path, $remarcs, $test_res, $date, $address, $phone,
$illness, $echo, $pmhx, $pshx, $habbits, $occup, $allergy, $pe, $id);
$stmt->execute();
if($stmt->errno){
echo "FAILURE!!! " . $stmt->error;
}
else {
header("location:update_done.php");
}
?>
现在我收到这个错误:
Fatal error: Call to a member function bind_param() on a non-object in So any help with this ?
最佳答案
prepare()
方法在出现错误时返回 false here .您应该将其保存在 if
语句中。
您的查询字符串不会解释变量 $tbl_name
,因为您使用的是单引号。它可以用 '.$tbl_name.'
修复。
关于php - 在我的新代码中对非对象执行 bind_param() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33561547/
是否可以使用 bind_param()用数组? 例如 $stmt->bind_param('iss', Array(101, 'SomeString 1', 'Some string 2')); //
我有一个 mysqli 查询,其 where 子句是在 for 循环中生成的。所以参数在运行前是未知的。 在这种情况下我如何使用 mysqli bind_param 方法? 我可以在for循环中使用它
我正在学习如何避免 SQL 注入(inject),但我有点困惑。 使用bind_param时,我不明白其用途。在手册页上,我找到了这个示例: $stmt = mysqli_prepare($link,
我在将值绑定(bind)到 php 中的 mysql 查询时遇到问题。 $this->conn->prepare("SELECT * FROM tablename LIMIT ? , ? "); $p
我一直都有 error_reporting,而且我已经检查了很多次,所以我想我可能调用了一个错误的值或者没有声明正确的东西。任何人都可以跳进来告诉我代码是怎么回事,为什么仍然出现错误“在非对象上调用成
这个问题在这里已经有了答案: warning :: invalid object or resource mysqli_stmt. What is the meaning and solution(s
这个问题在这里已经有了答案: What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must
我有一个mysqli查询,其where子句在for循环中生成。因此,参数在运行时之前未知。 在这种情况下,如何使用mysqli bind_param方法? 我可以在for循环中使用它来一一绑定参数吗?
此代码记录某个目录中的所有文件名。文件名将存储到特定的数据库表中。这是我的代码 "; $query = $connect->prepare("INSERT INTO ? SET img_lin
如何参数化以下查询并将散列字符保留在 $dienste_id 中? $sql = "UPDATE emails SET `emails_status` = CONCAT(emails_status,
我在 mysql 和 php 中遇到错误我的代码: $stmt->prepare("INSERT `tablename` (col1,col2,col3) VALUES (?,?,?)"); $stm
我遇到了 bind_param 函数的问题。我将在下面发布所有信息。 错误: Fatal error: Call to a member function bind_param() on a non-
我正在尝试使用 PHP 和 mysqli 理解准备好的语句。我试着阅读一些教程、手册和这个:Bind_Param in PHP ,但我还没有找到任何令人满意的答案。 有人在回答中写道: When yo
我一直在阅读 SQL 注入(inject),但我找不到这个问题的答案。 我明白如果我这样查询 prepare("SELECT id, foo, bar FROM table WHERE usernam
我遇到了以下代码没有结果的问题。但是,如果我取消注释掉指定的行,并注释掉它起作用的 bind_param 行,但这不是破坏了 mysqli 的目的吗?我的 var_dump 给了我的字符串(1)“1”
我正在尝试为用户制作一个可编辑的个人资料。他们单击编辑按钮(表单发布)返回带有可编辑信息的页面(仅当在文本区域中设置($_POST["edit"])、输入和“完成编辑”按钮时。当我点击完成编辑。它需要
是否可以迭代调用bind_param 和execute,或者我必须在每次迭代开始时准备一个语句吗? $query = $db->prepare('...'); foreach ($dataItem a
如果该变量存在,我正在尝试将参数绑定(bind)到 INSERT INTO MySQLi 准备语句,否则插入 null。 这是我拥有的,但它不起作用: if (!empty($name)) {
$resultSpendStmt = $connection->prepare(...); $array->bind_param("sdidi", $A, $B, $C, $D, $E); $arra
这个问题在这里已经有了答案: How to bind an array of strings with mysqli prepared statement? (6 个答案) 关闭 2 年前。 如果不
我是一名优秀的程序员,十分优秀!