我看不到我的错误来自哪里,我检查了分号并且看不到任何缺失。我对php相当陌生,非常感谢您的帮助。实际错误如下:
解析错误:语法错误,第 54 行 /home/sam/public_html/query.php 中的意外 T_VARIABLE
以下是第 54 行:
$sql = "UPDATE Users SET Datecreated='".$date."' WHERE Username='".$usernamec."'";
这是完整的代码:
<?php session_start();
include 'connect.php';
echo "Hello World!";
echo '$_SESSION[page]';
$_SESSION['loggedon']=12345;
$username=$_POST['username'];
$password=$_POST['password'];
$sql = "SELECT * FROM 'Users' WHERE 'Username'='".$username."'";
$result = @mysql_query( $sql );
while ($row= @mysql_fetch_assoc($result))
{
if (($username=$row['Username'])&&($password=$row['Password']))
{
$_SESSION['loggedon']=$row['AccessLevel'];
$_SESSION['userid']=$row['UserID'];}}
if ($_SESSION['loggedon']==12345)
{
$sql = "SELECT * FROM 'RedundantUsers' WHERE 'Username'='".$username."'";
$result = @mysql_query( $sql );
while ($row= @mysql_fetch_assoc($result))
{
$_SESSION['loggedon']=$row['AccessLevel'];
$_SESSION['userid']=$row['UserID'];
$userid =$row['UserID'];
$forename =$row['Forename'];
$surname =$row['Surname'];
$email =$row['Email'];
$usernamec =$row['Username'];
$access =$row['AccessLevel'];
$sql = "INSERT INTO 'Users' ('UserID', 'Forename', 'Surname', 'Email', 'Username', 'AccessLevel')
VALUES ('$userid', '$forename', '$surname', '$email', '$usernamec', '$access')";
if (!@mysql_query($sql))
{
die('Error: ' . mysql_error());
}
$sql = "DELETE * FROM 'RedundantUsers' WHERE 'Username'='".$usernamec."'"; }}
date_default_timezone_set('UTC');
$date = date("Y-m-d H:i:s");
$sql = "UPDATE 'Users' SET 'Datecreated'='".$date."' WHERE 'Username'='".$usernamec."'";
if (!@mysql_query($sql))
{
die('Error: ' . mysql_error());
}
echo $_SESSION['loggedon'];
header('Location: /'.$_SESSION['page']);
?>
万一它有帮助,这里是connect.php:
<?php
$dbhost = '*****';
$dbuser = '*****';
$dbpass = '*****';
$conn = @mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to local MySQL')
$dbname = '******';
@mysql_select_db($dbname);
?>