-4

您好,我的脚本有问题,它不会以任何形式创建并连接到我的数据库。这是我的代码:

<?php
$host="fdb4.biz.nf"
$username="1373217_users";
$passowrd="1234";
$db_name="1373217_users"; // Database name 
$tbl_name="members"; // Table name 

mysql_connect("$host", "$username", "$passowrd") or die("Database could not connect");
mysql_select_db("$db_name") or die("Database selected could not be found");
$sql="INSERT INTO `members` ('user') VALUES ('$_POST[username]')";

$username=$_POST['username'];
$password=$_POST['password'];

$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

$sql="INSERT INTO `members` (`username`)  VALUES ('{$_POST['username']}')";


// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>

这是 login.php,它给我的错误是:

解析错误:语法错误,第 4 行 /srv/disk11/1373217/www/tracklist.co.nf/login.php 中的意外 T_VARIABLE

谁能告诉我为什么?谢谢。

4

2 回答 2

4

您有一个语法错误,您错过了在 $host 语句之后放置分号,如下所示

 $host="fdb4.biz.nf";
于 2013-04-25T11:32:42.417 回答
1

问题是你把'(单引号)放在user你忘了;附近$host="fdb4.biz.nf"

改变这个

$sql="INSERT INTO `members` ('user') VALUES ('$_POST[username]')";

$sql="INSERT INTO `members` (`user`) VALUES ('$_POST[username]')";
于 2013-04-25T11:33:44.430 回答