Hayford
August 24, 2022, 12:35am
22
<?php
session_start();
include('dbconn.php');
if(isset($_POST['login'])){
$username=$_POST['username'];
$password=$_POST['password'];
$password = md5($password);
$stmt=$mysqli->prepare("SELECT username,email,password,id FROM admin WHERE (userName=?|| email=?) and password=? ");
$stmt->bind_param('sss',$username,$email,$password);
$stmt->execute();
$stmt -> bind_result($username,$email,$password,$id);
$rs=$stmt->fetch();
$_SESSION['id']=$id;
$uip=$_SERVER['REMOTE_ADDR'];
$ldate=date('d/m/Y h:i:s', time());
if($rs){
header("location:dashboard.php");
} else {
echo "<script>alert('Invalid Username/Email or password');</script>";
}
}
?>
// I have copied the dbconfig to the admin dir but the problem still persists
Fatal error : Call to a member function prepare() on null in /home/vol13_2/epizy.com/epiz_31818964/htdocs/admin/index.php on line 8
Oxy
August 24, 2022, 12:39am
23
ok that part is now fine
now give us the content of dbconn.php (let’s check if everything is fine there)
BUT HIDE ALL IMPORTANT INFORMATION
before you stick it here
if everything is fine in it
then your code from admin/index.php is to blame
OR
Is there a database created at all?
1 Like
Hayford
August 24, 2022, 12:44am
24
<?php
try {
$server = 'sql104.epizy.com';
$username = 'epiz_31818964';
$password = '**********';
$database = 'epiz_31818964_**********';
//$con=mysqli_connect("localhost","root","","hostel") or die('DATABASE connection failed');
$con = new mysqli($server, $username, $password, $database) or die("not connected");
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>
// This the dbconfig codes
Can you unhide the DB name, then screenhost the PHPMyAdmin section of the control panel?
2 Likes
Admin
August 24, 2022, 8:34am
27
I don’t think that’s the way to check for connection errors with mysqli in object oriented style.
Can you please change it so it looks more like example 1 from the PHP docs? PHP: mysqli::$connect_error - Manual
3 Likes
Hayford
August 24, 2022, 10:01am
28
Fatal error : Uncaught Error: Call to a member function prepare() on null in /home/vol13_2/epizy.com/epiz_31818964/htdocs/admin/index.php:8 Stack trace: #0 {main} thrown in /home/vol13_2/epizy.com/epiz_31818964/htdocs/admin/index.php on line 8
Bosses I have this error now, please do do i call to a member function prepare () on null
Can you please share your updated connection code? The only thing you have to hide is the password.
2 Likes
<?php
$server = 'sql104.epizy.com';
$username = 'epiz_31818964';
$password = '*******';
$database = 'epiz_31818964_hostelmsphp';
//$con=mysqli_connect("localhost","root","","hostel") or die('DATABASE connection failed');
$con = new mysqli($server, $username, $password, $database) or die("not connected");
if ($con->connect_error) {
/* Use your preferred error logging method here */
error_log('Connection error: ' . $con->connect_error);
}
?>`
Well you are defining your connection with Object Oriented PHP and you use the variable $con
.
And I think you are using PDO to send the query. And you are using the variable $mysqli
So you need to use the same type of PHP, and you certainly need to use the same variables.
3 Likes
<?php
$server = 'sql104.epizy.com';
$username = 'epiz_31818964';
$password = '******';
$database = 'epiz_31818964_hostelmsphp';
//$con=mysqli_connect("localhost","root","","hostel") or die('DATABASE connection failed');
//$con = new mysqli($server, $username, $password, $database) or die("not connected");
//if ($con->connect_error) {
/* Use your preferred error logging method here */
// error_log('Connection error: ' . $con->connect_error);
//}
mysqli_report(MYSQLI_REPORT_OFF);
/* @ is used to suppress warnings */
$mysqli = @new mysqli($server, $username, $password, $database);
if ($mysqli->connect_error) {
/* Use your preferred error logging method here */
error_log('Connection error: ' . $mysqli->connect_error);
}
?>
It works now after the modifcation in the dbconfig file
Thanks so much
Username (epiz_31818964) or
Website URL kstuhallbooking.42web.io
Error Message
Fatal error : Uncaught Error: Call to a member function bind_param() on bool in /home/vol13_2/epizy.com/epiz_31818964/htdocs/admin/check-availability.php:11 Stack trace: #0 {main} thrown in /home/vol13_2/epizy.com/epiz_31818964/htdocs/admin/check-availability.php on line 11
1 Like
Please do not create a new topic for the same issue. I merged your new post
Also, don’t use the “@” sign, because you want to display warnings. Please try debugging on your own before you post here.
4 Likes
system
Closed
August 31, 2022, 4:12pm
35
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.