PHP.ini引起警告:mysqli_error()期望参数1为mysqli,在第19行的/sys/index.php中给出null [英] PHP.ini causes Warning: mysqli_error() expects parameter 1 to be mysqli, null given in/sys/index.php on line 19
本文介绍了PHP.ini引起警告:mysqli_error()期望参数1为mysqli,在第19行的/sys/index.php中给出null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此脚本可在本地主机和其他免费主机上正常运行,但不能在主机Gator"上正常运行,它应该是"PHP.ini".任何帮助!
function.php
this script works fine on Local Host and Other free Hosting but not on "host Gator "it should be " PHP.ini " Any Help !?!?
<?php
date_default_timezone_set("America/Chicago");
echo date("Y/m/d H:i:s");
function consql($con){
$con=mysqli_connect("host","BDusername","DBPassWord","DB") or die( mysqli_error($con));}
?>
index.php
第1行非常热门"
index.php
line #1 "Very top "
<?php
SESSION_START();
require_once"inc/function.php";
consql($con);
?>
第12行
<?php
if(isset($_SESSION['user']))
{
header("location:users.php");
}
elseif(isset($_POST['submit']))
{
$result=mysqli_query("select user_id,password from user_login where name='$_POST[username]'") or die(mysqli_error($con)); // ** line # 19 ** //
$n=mysqli_fetch_assoc($result);
if($n['password']!=$_POST['userpassword'])
{
echo "user name or password wrong";
}
else
{
echo "you loged in as $_POST[username]";
$_SESSION['user']=$n['user_id'];
header("location:users.php");
}
}
else
我是mysqli的新手,在这里查找了同样的错误,但大多数人都没明白.
I'm new to mysqli and looked up here for same error but didn't get the point on most of them.
推荐答案
U可以使用
function consql(&$con){
$con=mysqli_connect("host","BDusername","DBPassWord","DB") or die( mysqli_error($con));
}
因此这是通过引用进行的,一旦U调用函数
so this is call by refrence and $con can use at any page once U call the function
或在连接线之前使用global $con;
这篇关于PHP.ini引起警告:mysqli_error()期望参数1为mysqli,在第19行的/sys/index.php中给出null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文