錯誤:*解析錯誤:語法錯誤,在第9行意外T_VARIABLE * < - 仍然給了我同樣的錯誤..錯誤的PDO聲明
PHP
<?php
#connect mysql
require_once "dbcred.php";
$dbh = testdb_connect();
session_start();
$username = $_POST['regduser'];
$userpass = md5($_POST['regdpass']);
$sql = $pdo->prepare("SELECT * from Students WHERE regduser=:username and regdpass=:pass");
$sql->bindParam(':username', $username)
$sql->bindParam(':pass', $userpass)
$sql->execute();
$result = mysql_query($sql);
if (mysql_num_rows($result)!= 1) {
$error = "Login failed";
#include "loginform.php";
} else {
echo "<h1>exists</h1>";
#$_SESSION['regduser'] = "$username";
#$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
// any other data needed to navigate the site or
// to authenticate the user can be added here
#include "membersection.php";
}
?>
dbcred.php
<?php
# pdo_testdb_connect.php - function for connecting to the "test" database
function testdb_connect()
{
$dbh = new PDO("mysql:host=localhost;dbname=#", "root", "");
return ($dbh);
}
?>
HTML:
<form action="inc/check_regUsr.php" method="post" id="userLogon">
<div class="field required">
Username: <input type="text" name="regduser" tabindex="1" /><br />
</div>
<div class="field required">
Password: <input type="text" name="regdpass" tabindex="2" /><br />
</div>
<input type="submit" name="submitUser" />
</form>
請參閱更新的第一代碼塊,它仍然給我同樣的錯誤。 – Jshee
@ user700070已更新。 – Jacob