适用于localhost,在线错误 [英] Works on localhost, error online

查看:79
本文介绍了适用于localhost,在线错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在PHP中离线开发了一个网站,并使用MySQL连接到数据库。在localhost上一切正常,我能够按照预期连接并在网站上工作。但是,现在网站已经存在,我在尝试登录时收到以下错误。



致命错误:调用成员函数execute()on第25行/usr/www/users/citeqqyvdw/parysxplore.info/administrator/validate.php中的非对象



现在这对我来说没有意义,它连接到数据库和一切,但它似乎没有收到一个对象。这可能是什么问题?



这是我的代码:



I have developed a website offline in PHP and connect to a database using MySQL. On localhost everything was working fine and I was able to connect and work on the website as intended. However, now that the website is live, I am receiving the following error when I try to log in.

Fatal error: Call to a member function execute() on a non-object in /usr/www/users/citeqqyvdw/parysxplore.info/administrator/validate.php on line 25

Now this does not make sense to me, it connects to the database and everything, but it does not receive an object it seems. What could be the problem here?

This is my code:

<?php
	session_start();   
	
	ini_set('display_errors',1); 
 error_reporting(E_ALL);
	
    if(isset($_REQUEST['admin']) && isset($_REQUEST['password'])) {
        $hostname = "(some database)";
		$username = "xplore";
		$db_password = "(password)";
		$database = "xplore_db";
        
        $admin = $_REQUEST['admin'];
        $password = $_REQUEST['password'];
        
        $mysqli = @new mysqli($hostname, $username, $db_password, $db_name);
            
        if(mysqli_connect_errno()) {
            echo "Unable to connect";
        } else {
	
            $sql = "SELECT admin_user_name, admin_password FROM admin_login WHERE admin_user_name = '$admin' AND admin_password = '$password'";            
                
            $statement = $mysqli->prepare($sql);
			$statement->execute();
			$statement->bind_result($admin_username, $admin_password);
						
	
            while($statement->fetch()) {
				$_SESSION['valid_admin'] = $admin_username; 
			}
            $mysqli->close();                
        }
    }
	
    if(isset($_SESSION['valid_admin'])) {
        header("Location: admin.php");
    } else {
		global $result;
		$result = "Incorrect Administration <br/> details provided!";
    }        
?>





问候,

Chris



Regards,
Chris

推荐答案

_REQUEST [' admin'])&& isset(
_REQUEST['admin']) && isset(


_REQUEST [' password'])){
_REQUEST['password'])) {


hostname = (某些数据库);
hostname = "(some database)";


这篇关于适用于localhost,在线错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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