我是 PHP 编码的新手,我在以下代码中找不到错误...你能帮帮我吗?
致命错误:不能在 C:\wamp\www\membre\inscription_post.php 第 14 行调用堆栈 # 时间记忆函数位置 1 0.0006 682688 {main}( ) ..\inscription_post.php:0 中使用 PDOStatement 类型的对象作为数组
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=test', 'root', '');
}
catch(Exception $e)
{
die('Erreur : '.$e->getMessage());
}
$mem = $bdd -> query('SELECT * FROM membres');
while ($data = $mem -> fetch())
{
if($mem['pseudo'] == $_POST['pseudo'])
{
echo "Pseudo existant";
}
else
{
$pass_hache = sha1($_POST['pass']);
$req = $bdd->prepare('INSERT INTO membres (pseudo, pass, email, date_inscription) VALUES(?, ?, ?, CURDATE())');
$req->execute(array($_POST['pseudo'], $pass_hache, $_POST['email']));
header('Location: inscription.php');
echo "Membre ajouté";
}
}
$mem -> closeCursor();
?>
membres
表结构如下
id(=INT, primary key),
pseudo (VARCHAR(255)),
pass (VARCHAR(255)),
date_inscription (date)
感谢您的帮助