1
我想將使用mysql_connect的代碼轉換爲pdo,但是我不知道在此之後要做什麼。應該放置「mysql_result」。PHP將mysql_connection轉換爲PDO
$query = "select * from tbl_usuarios where login = '$cliente_username' and senha = '$cliente_password'";
$result = $conexao->query($query);
$number = $result->fetch();
if ($number==0) { ?><script>alert('Dados incorretos! Tente novamente.');</script>
<?php
exit;
} else {
$_SESSION['usuario_id'] = mysql_result($result,0,'id');
$_SESSION['usuario_nome'] = mysql_result($result,0,'nome');
?><script>document.location = '../principal.php'</script><?php
}
mysql_close($conexao);
}
?>
解決\t $ _SESSION ['usuario_id'] = $ number ['id']; \t $ _SESSION ['usuario_nome'] = $ number ['nome']; – 2014-10-11 21:37:41