有关php的问题

来源:百度知道 编辑:UC知道 时间:2024/06/09 03:02:54
<?
session_start();
$admin_name=$_POST['admin_name'];
$admin_password=$_POST['admin_password'];
$conn=mysql_connect ("localhost", "root", "123456");
mysql_select_db("guest_book");
$exec="select * from admin_name where admin_name='".$admin_name."'";
$res=mysql_query($exec);
if(mysql_num_rows()>0)///若有此用户
{
$row=mysql_fetch_array($res);
////判断用户是否正确
if($row['admin_name']==$admin_name and $row['admin_password']==$admin_password)
{
session_start();
session_register("admin_name");
echo "<script>";
echo "elert(\"欢迎回来\");";
echo"location.href=\"admin_index.php"\";";
echo"</script>";
else{
echo"<script>";
echo"alert(\"密码错误\"

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in C:\AppServ\www\liuyan123\admin_check.php on line 19
```

第19行,缺少分号。。

echo 'elert(\"欢迎回来\");';
echo 'location.href=\"admin_index.php\";';
这样应该就可以了~

你的双引号嵌套表达式错误的。
如果有多重的 话,应该设置成不同的。

echo"location.href=\"admin_index.php"\";";
改为echo'location.href="admin_index.php"';

把echo"location.href=\"admin_index.php"\";";
改成
echo"location.href=\"test.php\";";