语法错误,第11行/home/allummfa/public_html/auth.php中的意外':' [英] syntax error, unexpected ':' in /home/allummfa/public_html/auth.php on line 11

查看:53
本文介绍了语法错误,第11行/home/allummfa/public_html/auth.php中的意外':'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好。我现在使用与上一个问题完全相同的代码得到上述错误。我所做的就是重新排列线条...没有代码更改......帮助!

为了帮助您的专家,第11行包含此代码 - 标题(?WWW-Authenticate:Basic realm =?secret然后当我删除冒号时,我在第11行的/home/allummfa/public_html/auth.php中收到一个新错误 - 语法错误,意外的T_STRING。

此代码应该告诉Web服务器将标头发送到客户端的浏览器,以在用户尝试访问我的受限制网页时提示输入用户名和密码。以下是我的完整编码:


<?php

/ *程序:Auth.php

* Desc:使用HTTP身份验证从用户提示输入用户名和

*密码的程序。

*该程序然后测试用户是否

*名称和密码匹配用户名和密码

*对存储在MySQL数据库中。

* /

//测试用户是否被提示输入用户名(!isset($ _ SERVER [?PHP_AUTH_USER?]))

{

header(?WWW-Authenticate:Basic realm) =?秘密部分??);

标题(?HTTP / 1.0 401未授权?);

退出(?此页面需要身份验证!?);} //测试用户输入的用户名和密码

else {

包括(?Vars.inc?);

$ user_name = trim($ _SERVER [?PHP_AUTH_USER?]);

$ user_password = trim($ _ SERVER [?PHP_AUTH_PW?]);

$ connection = mysql_connect($主机,$用户,$密码)或死(?无法连接到服务器。?);

$ db = mysql_select_db($ database,$ connection)或死(?无法选择数据库。?);

$ sql =?SELECT user_name FROM Valid_User WHERE user_name =?$ user_name?AND password = md5(?$ user_password?)?;

$ result = mysql_query($ sql)或死(?无法执行查询。?);

$ num = mysql_num_rows($ result);

if($ num< 1)//找不到用户名/密码

{

退出(?您输入的用户名或密码无效。< br>?);


}

}

//网页内容。

包括(?imagegallery.inc?) ;

?>

Hi again. I now get the above error with the exact same code as in my previous question. All I did was to rearrange the lines...no code changes...help!
To assist you experts, line 11 contains this code - header(?WWW-Authenticate: Basic realm=?secret section??);
Then when I remove the colon, I get a new error - syntax error, unexpected T_STRING in /home/allummfa/public_html/auth.php on line 11.
This code is supposed to tell the web server to send the headers to the client''s browser to prompt for a username and password when the user tries to access my restricted web page. Here''s my complete coding below:


<?php
/* Program: Auth.php
* Desc: Program that prompts for a user name and
* password from the user using HTTP authentication.
* The program then tests whether the user
* name and password match a user name and password
* pair stored in a MySQL database.
*/
//Testing whether the user has been prompted for a user nameif(!isset($_SERVER[?PHP_AUTH_USER?]))
{
header(?WWW-Authenticate: Basic realm=?secret section??);
header(?HTTP/1.0 401 Unauthorized?);
exit(?This page requires authentication!?);}// Testing the user name and password entered by the user
else{
include(?Vars.inc?);
$user_name = trim($_SERVER[?PHP_AUTH_USER?]);
$user_password = trim($_SERVER[?PHP_AUTH_PW?]);
$connection = mysql_connect($host,$user,$password)or die (?Couldn?t connect to server.?);
$db = mysql_select_db($database,$connection)or die (?Couldn?t select database.?);
$sql = ?SELECT user_name FROM Valid_User WHERE user_name = ?$user_name?AND password = md5(?$user_password?)?;
$result = mysql_query($sql)or die(?Couldn?t execute query.?);
$num = mysql_num_rows($result);
if ($num < 1) // user name/password not found
{
exit(?The User Name or Password you entered is not valid.<br>?);

}
}
//web page content.
include(?imagegallery.inc?);
?>

推荐答案

_SERVER [?PHP_AUTH_USER?]))

{

header(?WWW-Authenticate:Basic realm =?secret section ??);

header(?HTTP / 1.0 401 Unauthorized?);

exit( ?此页面需要验证!?);} //测试用户输入的用户名和密码

else {

include(?Vars.inc?);
_SERVER[?PHP_AUTH_USER?]))
{
header(?WWW-Authenticate: Basic realm=?secret section??);
header(?HTTP/1.0 401 Unauthorized?);
exit(?This page requires authentication!?);}// Testing the user name and password entered by the user
else{
include(?Vars.inc?);


user_name = trim(
user_name = trim(


_SERVER [?PHP_AUTH_USER?]);
_SERVER[?PHP_AUTH_USER?]);


这篇关于语法错误,第11行/home/allummfa/public_html/auth.php中的意外':'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆