Can't access database

bladminx

New Member
Messages
10
Reaction score
0
Points
1
I am on x14 server and had to wait for my files to be restored. Now that I finally have them back, I can't seem to log into my database. I keep getting error 500

Has the password been forcefully changed or something?

By the way, I CAN enter phpMyAdmin and my database is intact. The issue occurs when I try to access it via php.

Thanks in advance!
 

Anna

I am just me
Staff member
Messages
11,607
Reaction score
563
Points
113
How and where are you trying to login to the database when you get an error?

What is the full error?

Passwords should have remained the same during the process, however what could have happened is that your account was set to the wrong php version from what your script requires (or wrong extensions are enabled on the version you have).

You have the ability to change php version and enable/disable extenions under "Extra Features"->"Select PHP Version"
 

bladminx

New Member
Messages
10
Reaction score
0
Points
1
My current php version is 7.0.

I'm really bad at php-mysql queries, but the following code used to work:

<?php

function fetch_users()
{
$dbserver = "localhost";
$dbuser = "***";
$password = "***";
$dbname = "***";

$database = new mysqli($dbserver, $dbuser, $password, $dbname);

if($database->connect_errno)
{
die("Could not access database");
}

$link = mysqli_connect($dbserver, $dbuser, $password) or die("No he podido conectarme a '$dbserver'");
mysqli_select_db($link, $dbname) or die("No he podido abrir la base llamada '$dbname'");

$query = "SELECT email, lastnl, tdiff FROM users";

$result = mysqli_query($link, $query);

mysqli_close($database);

echo $result;

mysqli_free_result($result);
}

fetch_users();

?>

The two error messages I get are:

"Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

"crbug/1173575, non-JS module files deprecated.
(anonymous) @ (index):7288
"

Thanks again!
 

Anna

I am just me
Staff member
Messages
11,607
Reaction score
563
Points
113
I was more after on what link would I be able to reproduce the error, as in what are you doing on your site when the error pops up. If the code worked fine before and no edits were done it should still work, assuming the right set of php version and extensions are in play.

Seeing as you have the entire site behind username and pass I could take a stab at anything and not knowing if it did help or not as I can not see an error.

Though looking at the error log, the database connection is currently not the cause of the script to fail: Object of class mysqli_result could not be converted to string in /home/*******/domains/*******/public_html/*****.php on line 39

Filename would be where it looks like you took the code, judging from the contents of that file at least, though the file have more rows then the code pasted so I can't tell for sure.
 

bladminx

New Member
Messages
10
Reaction score
0
Points
1
I was more after on what link would I be able to reproduce the error, as in what are you doing on your site when the error pops up. If the code worked fine before and no edits were done it should still work, assuming the right set of php version and extensions are in play.

Seeing as you have the entire site behind username and pass I could take a stab at anything and not knowing if it did help or not as I can not see an error.

Though looking at the error log, the database connection is currently not the cause of the script to fail: Object of class mysqli_result could not be converted to string in /home/*******/domains/*******/public_html/*****.php on line 39

Filename would be where it looks like you took the code, judging from the contents of that file at least, though the file have more rows then the code pasted so I can't tell for sure.

Once again, thank you so much for your help! Following your advice I checked the PHP settings and it seems the problem was mysqli had been disabled. After reenabling it everything seems to work :)
 

gasolin2

New Member
Messages
16
Reaction score
0
Points
1
Hello Anna, for some unknown reason my .php stops and does not generate errors through DirectAdmin when I connect to the DB through mysqli_connect ::

$server = 'localhost' ; # Server (default:localhost)
$username = 'gasolin2_cocou' ; # Mysql database user
$password = 'xxxxxxxx' ; # Mysql database password
$database = 'gasolin2_cocod' ; # Mysql database

if (mysqli_connect($server, $username, $password, $database)) { echo "4.- Conex.Ok <br>"; }
else { echo "5.- Conex.NotOk <br>"; }

The server is correct, the username is correct, the password is correct and the DB is also correct.
Checked the BBDD through phpmyadmin, it exists, it is correct and it answers the SQL queries,
https://x14.x10hosting.com/phpMyAdmin/index.php ....... is Ok

Although everything seems correct, no error of any kind is generated, but the execution of .php stops and we don't know where the problem is. Can somebody help me?
Thank you very much in advance and best regards.
 
Last edited:

spacresx

Community Advocate
Community Support
Messages
1,621
Reaction score
129
Points
63
you should open a new post for your issue.
posting to a post that has already been answered might not be viewed by staff.
usually support for scripts is not provided.
unless it pertains to a service provided by x10hosting.
 

gasolin2

New Member
Messages
16
Reaction score
0
Points
1
Hello Anna, as indicated in the post title "Can't access database" would you be so kind as to please give us some guidance to solve this mysqli_connect problem? This is not a script, it is a connection problem with the database.
Or failing that, indicate the existing post url where we can find a favorable solution.

We understand that x14.x10hosting.com/phpMyAdmin/index.php is a service provided by x10hosting.
Thank you very much in advance and best regards.
 
Last edited:

Eric S

Administrator
Staff member
Messages
522
Reaction score
60
Points
28
Hello Anna, as indicated in the post title "Can't access database" would you be so kind as to please give us some guidance to solve this mysqli_connect problem? This is not a script, it is a connection problem with the database.
Or failing that, indicate the existing post url where we can find a favorable solution.

We understand that x14.x10hosting.com/phpMyAdmin/index.php is a service provided by x10hosting.
Thank you very much in advance and best regards.
Are you attempting to make these connections from within your localhost being hosted on the same service?
 

gasolin2

New Member
Messages
16
Reaction score
0
Points
1
Yes. All is over x10hosting. You can probe::
And you can see result::
20221013:101440 0.- Init... ChkIp:xxx.xxx.xxx.xxx ..&.. CheckHost:gasolineras.x10host.com
20221013:101440 1.- Url.... http://gasolineras.x10host.com/01inc/61test.php?&q=sysop
20221013:101440 2.- Getting require_once('00conn.php')
20221013:101440 3.- BBDD... Server:localhost ..&.. Name:gasolin2_cocod
20221013:101440 4.- Now.... Connecting: = mysqli_connect(localhost, gasolin2_cocou, *password, gasolin2_cocod)
X.- Here should have connected. However, the process stops and does not continue or generate any type of error, why?

Here you can see another site where the same connection works correctly::
20221013:101908 0.- Init... ChkIp::xxx.xxx.xxx.xxx ..&.. CheckHost::xxx.xxx.xxx.xxx
20221013:101908 1.- Url.... http://:xxx.xxx.xxx.xxx/01inc/61test.php?&q=sysop
20221013:101908 2.- Getting require_once('00conn.php')
20221013:101908 3.- BBDD... Server:localhost ..&.. Name:data1400
20221013:101908 4.- Now.... Connecting: = mysqli_connect(localhost, root, *password, data1400)
20221013:101908 5.- Conex.Ok
20221013:101908 6.- 32b/64b, No response 32 Bits
20221013:101908 7.- Linux localhost 4.14.186+ #1 SMP PREEMPT Thu May 5 15:43:55 CST 2022 aarch64

Not being able to keep this test private for so long (more than 10 days), when someone responds it will be activated again.
 
Last edited:
Top