[英]MYSQL Update Connection Error with ->
I am doing an update statement into my database. 我正在对数据库进行更新。 My connection has been done properly. 我的连接已正确完成。 However there is an issue. 但是有一个问题。 After $conn->
the remaining of my codes are being displayed out just like echo instead of the update statement updating the database. 在$conn->
之后,我的其余代码将像echo一样显示出来,而不是显示更新数据库的更新语句。 I have been trying to debug it but nothing seems to work. 我一直在尝试调试它,但似乎没有任何效果。 Unsure of the error. 不确定错误。 Do help to identify the error. 请帮助识别错误。
<?php//check on the updating
if (isset($_POST['set'])){
$query = 'UPDATE default SET sql_statement ="'.$_POST['sql'].'", x_axis = "'.$_POST['x'].'", y_axis = "'.$_POST['y'].'" WHERE id = "'.$id.'" ';
$result = $conn->query($query);
if($result){
header('Location:previewgraphs.php?id='.$id);
die();
}
}
?>
Try this: 尝试这个:
<?php//check on the updating
if (isset($_POST['set'])){
$query = 'UPDATE default SET sql_statement ="'.$_POST['sql'].'", x_axis = "'.$_POST['x'].'", y_axis = "'.$_POST['y'].'" WHERE id = "'.$id.'" ';
$result = $conn->query($query);
if($result){
header('Location:previewgraphs.php?id='.$id);
die();
}
}
?>
Some where your php tags have problem. 一些你的PHP标签有问题。 So use "
to wrap and also when you are using array
index in concatenation, wrap them with {}
因此,请使用"
换行,并且当您在串联中使用array
索引时,请用{}
换行
<?php
if (isset($_POST['set'])){
$query = "UPDATE default SET sql_statement ='{$_POST['sql']}', x_axis ='{$_POST['x']}', y_axis = '{$_POST['y']}' where id = $id";
$result = $conn->query($query);
header('Location:previewgraphs.php?id='.$id);
}
?>
<?php//check on the updating
if (isset($_POST['set'])){
$query = "UPDATE default SET sql_statement ='".$_POST['sql']."', x_axis = '".$_POST['x']."', y_axis = '".$_POST['y']."' WHERE id = '".$id."'";
$result = $conn->query($query);
if($result){
header('Location:previewgraphs.php?id='.$id);
die();
}
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.