php在Linux环境下报了MYSQL错误
在Windows环境下一切正常,上传到Linux服务器上就出问题了,错误如下,琢磨了一天没有个结果........Warning:mysqli::mysqli()[fun...
在Windows环境下一切正常,上传到Linux服务器上就出问题了,错误如下,琢磨了一天没有个结果........
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (00000/1130): Host 'ksftp.ivo.com.cn' is not allowed to connect to this MySQL server in /usr/local/apache/htdocs/IvoRtt/db_fns.php on line 4
Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in /usr/local/apache/htdocs/IvoRtt/user_auth_fns.php on line 42
You could not be logged in. You must be logged in to view this page.
第一个错误在 db_fns.php 页面,代码片段为:
<?php
function db_connect() {
$result = new mysqli('192.168.253.103', 'xxxxx', 'xxxxxx', 'ivortt');
if (!$result) {
throw new Exception('Could not connect to database server');
}else{
return $result;
}
}
?>
做数据单笔连接数据库测试可以读写到。
第二个错误在 user_auth_fns.php
function login($username, $password){
// check username and password with db
// if yes, return true
// else return false
// connect to db
$conn = db_connect();
if (!$conn)
return false;
// check if username is unique
$result = $conn->query("select * from user
where username='$username'
and passwd ='$password'");
if (!$result) {
throw new Exception('Could not log you in.');
}
if ($result->num_rows>0) {
return true;
}else{
throw new Exception('Could not log you in.');
}
}
服务器是Liux环境权限都是 777 全开的,
症状是从登陆页面login.php进去后member.php页面上报错的,
member.php部分代码如下:
<?php
// include function files for this application
require_once('ivortt_fns.php');
session_start();
//create short variable names
$username = $_POST['username'];
$passwd = $_POST['passwd'];
if ($username && $passwd){
// they have just tried logging in
try{
login($username, $passwd);
// if they are in the database register the user id
$_SESSION['valid_user'] = $username;
}
catch (Exception $e){
// unsuccessful login
//do_html_header('Problem:');
echo 'You could not be logged in.
You must be logged in to view this page.';
// do_html_url('login.php', 'Login');
// do_html_footer();
exit;
}
}
do_html_header('');
// get the bookmarks this user has saved
if ($url_array = get_user_urls($_SESSION['valid_user'])) {
display_user_urls($url_array);
}
if (isset($_SESSION['valid_user']))
{
// give menu of options
include('resume_index.php');
}
else
{
include("wrong_logout.php");
}
echo '<a herf ="authmain.php"Back to main page</a>';
do_html_footer();
?>
麻烦各位大侠援助小弟.
1楼可以详细说明下吗?赋予这个用户什么权限?
我还不能贴图能在线给我解释下吗?我自己添加了个用户不过问题依然存在 展开
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (00000/1130): Host 'ksftp.ivo.com.cn' is not allowed to connect to this MySQL server in /usr/local/apache/htdocs/IvoRtt/db_fns.php on line 4
Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in /usr/local/apache/htdocs/IvoRtt/user_auth_fns.php on line 42
You could not be logged in. You must be logged in to view this page.
第一个错误在 db_fns.php 页面,代码片段为:
<?php
function db_connect() {
$result = new mysqli('192.168.253.103', 'xxxxx', 'xxxxxx', 'ivortt');
if (!$result) {
throw new Exception('Could not connect to database server');
}else{
return $result;
}
}
?>
做数据单笔连接数据库测试可以读写到。
第二个错误在 user_auth_fns.php
function login($username, $password){
// check username and password with db
// if yes, return true
// else return false
// connect to db
$conn = db_connect();
if (!$conn)
return false;
// check if username is unique
$result = $conn->query("select * from user
where username='$username'
and passwd ='$password'");
if (!$result) {
throw new Exception('Could not log you in.');
}
if ($result->num_rows>0) {
return true;
}else{
throw new Exception('Could not log you in.');
}
}
服务器是Liux环境权限都是 777 全开的,
症状是从登陆页面login.php进去后member.php页面上报错的,
member.php部分代码如下:
<?php
// include function files for this application
require_once('ivortt_fns.php');
session_start();
//create short variable names
$username = $_POST['username'];
$passwd = $_POST['passwd'];
if ($username && $passwd){
// they have just tried logging in
try{
login($username, $passwd);
// if they are in the database register the user id
$_SESSION['valid_user'] = $username;
}
catch (Exception $e){
// unsuccessful login
//do_html_header('Problem:');
echo 'You could not be logged in.
You must be logged in to view this page.';
// do_html_url('login.php', 'Login');
// do_html_footer();
exit;
}
}
do_html_header('');
// get the bookmarks this user has saved
if ($url_array = get_user_urls($_SESSION['valid_user'])) {
display_user_urls($url_array);
}
if (isset($_SESSION['valid_user']))
{
// give menu of options
include('resume_index.php');
}
else
{
include("wrong_logout.php");
}
echo '<a herf ="authmain.php"Back to main page</a>';
do_html_footer();
?>
麻烦各位大侠援助小弟.
1楼可以详细说明下吗?赋予这个用户什么权限?
我还不能贴图能在线给我解释下吗?我自己添加了个用户不过问题依然存在 展开
4个回答
展开全部
Host 'ksftp.ivo.com.cn' is not allowed to connect to this MySQL server
192.168.253.103是你的数据库服务器吧.
在mysql中,用户的标识都是 "username"@"host"
而在你'192.168.253.103'这台mysql服务器中 没有一个用户的 “host”项满足 ksftp.ivo.com.cn这个主机,所以mysq连接失败。
建议你在'192.168.253.103'mysql服务器里面添加一个用户 username@% 然后把你的数据库权限赋给改用户, 你php程序就可以用username这个用户名去连接mysql服务器了
192.168.253.103是你的数据库服务器吧.
在mysql中,用户的标识都是 "username"@"host"
而在你'192.168.253.103'这台mysql服务器中 没有一个用户的 “host”项满足 ksftp.ivo.com.cn这个主机,所以mysq连接失败。
建议你在'192.168.253.103'mysql服务器里面添加一个用户 username@% 然后把你的数据库权限赋给改用户, 你php程序就可以用username这个用户名去连接mysql服务器了
展开全部
下面说的有道理,O(∩_∩)O~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
服务器没连接上,,,,换到本地用localhost试一下,,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询