Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php提交与PDO SQL问题_Php_Mysql_Pdo - Fatal编程技术网

php提交与PDO SQL问题

php提交与PDO SQL问题,php,mysql,pdo,Php,Mysql,Pdo,我想从普通的mysql查询改为PDO,但从那时起,我甚至无法追溯故障 有人帮我吗?任何暗示都将不胜感激 问题1:怎么了?问题2:一般如何跟踪故障 <?php // Check if add button active, start this if (isset($_POST['create'])) { $new=htmlspecialchars($_POST['newgroup']); $sql = "INSERT INTO contactgroups (status, gr_name

我想从普通的mysql查询改为PDO,但从那时起,我甚至无法追溯故障

有人帮我吗?任何暗示都将不胜感激

问题1:怎么了?问题2:一般如何跟踪故障

<?php
// Check if add button active, start this
if (isset($_POST['create'])) {
 $new=htmlspecialchars($_POST['newgroup']);
 $sql = "INSERT INTO contactgroups (status, gr_name) VALUES(1, : new )";
 $sql->bindvalue( ': new', $new);
 $sql->execute();
 $arr = $sql->errorInfo();
 echo $arr;
 echo  "<meta http-equiv=\"refresh\" content=\"0;URL=groups.php\">";
}
?>

<form id="group-in" method="post" action="groups.php">
Add new Distribution group: <input type="text" name="newgroup" placeholder="name..."> <input type="submit" name="create" value="Create new">
Rename groupname: <input type="text" value="<?php echo $result['gr_name']; ?>"> <input type="submit" name="rename" value="Rename">
</form>

添加新通讯组:

重命名groupname:您从未准备过上面的sql语句

为了运行,您首先需要初始化DB并创建一个新的PDO实例。假设您以前做过此操作:

<?php
// Check if add button active, start this
if (isset($_POST['create'])) {
 $new=htmlspecialchars($_POST['newgroup']);
 $sql = "INSERT INTO contactgroups (status, gr_name) VALUES(1, : new )";
 $stmt = $db->prepare($sql);
 $stmt->bindvalue( ': new', $new);
 $stmt->execute();
 $arr = $stmt->errorInfo();
 echo $arr;
 echo  "<meta http-equiv=\"refresh\" content=\"0;URL=groups.php\">";
}
?>


您可以使用try/catch语句包装函数/代码位,并使用PDO启用异常处理,以便更好地了解未来的错误。

您从未准备过上面的sql语句

为了运行,您首先需要初始化DB并创建一个新的PDO实例。假设您以前做过此操作:

<?php
// Check if add button active, start this
if (isset($_POST['create'])) {
 $new=htmlspecialchars($_POST['newgroup']);
 $sql = "INSERT INTO contactgroups (status, gr_name) VALUES(1, : new )";
 $stmt = $db->prepare($sql);
 $stmt->bindvalue( ': new', $new);
 $stmt->execute();
 $arr = $stmt->errorInfo();
 echo $arr;
 echo  "<meta http-equiv=\"refresh\" content=\"0;URL=groups.php\">";
}
?>


您可以使用try/catch语句包装函数/代码位,并使用PDO启用异常处理,以便更好地了解未来的错误。

谢谢,prepare肯定是错误之一。现在我有42000个错误代码???没有谷歌搜索结果吗?谢谢,准备肯定是错误之一。现在我有42000个错误代码???没有谷歌搜索结果?+1@Jürgen Thelen:那是另一个错误!!!!非常感谢。+1@Jürgen Thelen:那是另一个错误!!!!谢谢。