Martn
-
Posts
5 -
Joined
-
Last visited
Posts posted by Martn
-
-
I have 2 PHP scripts : opendb.php and closedb.php
In opendb.php I have this code :
<?php
session_start();
$conn = mysqli_connect(................................);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
} else {
echo "DB open.";
$_SESSION['dbhandler'] = $conn;
}
?>In closedb.php I have this code :
<?php
session_start();
$conn = $_SESSION['dbhandler']
mysqli_close($conn);
echo "DB closed";
?>
When I run opendb.php I get the expexted message "DB Open."
But when running the closedb.php , I get an error 500.
I was hoping to be able to pass the Handle, needed to operate in my database, between PHP scripts, by pushing it
into $_SESSION['dbhandler'] , and retreiving it in other scripts.
Is this possible ?
Regards,
Martin
-
Your question triggered my brain 🙂
I was testing (or trying to test...) from within DirectAdmin.
When I type the full URL in a new tab of my browser it works !
Regards,
Martin.
-
Hi Barand,
yes it does ...
Martin
-
I'm trying my first PHP code :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Contact Form</title>
</head>
<body><?php
echo "Hello world!";
?></body>
</html>Result : nothing, just a blank screen ...
Am I missing something ?
Regards,
Martin
Opening SQL DB fails
in MySQL Help
Posted
Hi,
My server is running PHP version 7.3
I'm getting the error
"Backend fatal error: PHP Fatal error: Uncaught Error: Call to undefined function mysqli()"
on this code to open my DB :
<?php
$servername = "localhost";
$username = "tester";
$password = "@Tester@";
$db = "test";
// Create connection
$conn = mysqli_connect($servername, $username, $password,$db);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}else {
echo "Connected successfully";
}
?>
Can someone give me hint on the mistake I'm making ?
Thanks.