hello dear experts here at Daniweb,

first of all i am pretty new to this site - to daniweb. I am new to this site. My interests are Programming in PHP, Python and running websites - with WordPress.

Well - i am running webadmin - a Apache and MySQL-Server-frontend- for years now. now i run into troubles when establishing a db connection.
i thought that during the installation process the file wp-config-sample.php gets to wp-config.php - but this is not happening.- i have gathered some more infos and inights due to some tests. see the following data: - the outcome of a testscript:

Warning: mysqli_connect(): (HY000/2002): No such file or directory in /sites/www.mysite.de/tests.php on line 
  Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /sites/www.mysite.de/tests.php on line could not connect

see the script;

    <?php
    if(function_exists('mysqli_connect')){
    if(!($link = mysqli_connect('localhost','user','passwd','my_db'))){
    die('could not connect: ' . mysqli_error($link));
    }
    } else {
    die("don't have mysqli");
    }
    echo 'connect successfully';
    mysqli_close($link);

on the webmin-frontend (that is the area i have to controll and configure all the stuff on the server')

1 USE yourdatabase;
2 SHOW GLOBAL VARIABLES LIKE 'PORT';
3 SHOW GRANTS FOR CURRENT_USER;

i get back the following results:
check the manual that corresponds to your MySQL server version for the right syntax to use near ''name of my db';

    SHOW GLOBAL VARIABLES LIKE 'PORT'; SHOW GRANTS FOR CURRENT_USER' at line 1

and the following

    Failed to execute SQL : SQL USE 'name of my db'; SHOW GLOBAL VARIABLES LIKE 'PORT';
    SHOW GRANTS FOR CURRENT_USER; failed : You have an error in your SQL syntax;

i am a bit unsure what i can do now.

well - since there is no connection_error property in mysqli. i think that i have to check connection error using

    if ($conn->connect_error) {
        die('Connect Error: ' . $conn->connect_error);
    }

i have to read the manpages here http://php.net/manual/en/mysqli.connect-error.php in order to learn what i need to get more insights.,

btw: I have Linux Server. Apache 2.4.10, PHP Version 5.6.39 and mysqlnd 5.0.11-dev - 20120503 - installed. There are several wordpress website running on server.

do i have MySQL or MySQLi - i am not sure.

how to get more insights ... ?

what would you do now!?

generally spoken:

  1. The now extinct mysql library and the mysqli library are two completely different animals.
  2. that s3aid - we surely can forget about mysqli and use PDO.
  3. i have to ponder on all the options and possibilities.
  4. Afterward i need to do more chekcs

see here a quick and dirty comparison of the different systems ...

    +---------+-------------+
    |  mysql  |  dodo ;)       |
    |  mysqli |  donkey ;)     |
    |  PDO    |  racehorse ;)  |

what can i do else.

i am willing to learn. And yes: i need to learn all bout the 1. The now extinct mysql library and the mysqli library are two completely different animals.

hello dear all

runned this code

<?php
$mysqli = new mysqli('localhost', 'my_user', 'my_password', 'my_db');

/*
 * This is the "official" OO way to do it,
 * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
 */
if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);
}

$mysqli->close();

and got back this

Parse error: syntax error, unexpected end of file in /sites/www.my-site.de/new_test.php on line 13

well what happened? i tryto figure it out

well - first of all many many thanks for the reply and the help and support. I am trying to figure out what has happened.
i am very glad to be here on this great place.

a big big sorry - for the bit of confusing thread-posting with the issues.
I am in need of help and i try to sort out things here.

some first statements:

i am on

PHP Version 5.6.39

btw: I have Linux Server - based on opensuse:

Apache 2.4.10, PHP Version 5.6.39 and
mysqlnd 5.0.11-dev - 20120503
the newest version of Webadmin - Webmin 1.910
see http://www.webmin.com/

i have testesd varios versions of the mysqli.connect-error-scripts...

see the results:
https://www.php.net/manual/en/mysqli.connect-error.php

mysqli::$connect_error
mysqli_connect_error
(PHP 5, PHP 7)

Example #1 $mysqli->connect_error example Object oriented style

<?php
$link = @mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');

if (!$link) {
    die('Connect Error: ' . mysqli_connect_error());
}
?>

and got back the following: Connect Error: No such file or directory

note: i also runned this with the adviced replacement of localhost with 127.0.0.1 ... see below:

<?php
$link = @mysqli_connect(''127.0.0.1'', 'user', 'db-passwd', 'db-name');

if (!$link) {
 die('Connect Error: ' . mysqli_connect_error());
}
?>

and i got back here:

Connect Error: No such file or directory    

...and here we have more insights - i also runned the PDO-version: see: https://www.w3schools.com/php/php_mysql_connect.asp

Note: In the PDO example above we have also specified a database (myDB). PDO require a valid database to connect to.
If no database is specified, an exception is thrown.
Tip: A great benefit of PDO is that it has an exception class
to handle any problems that may occur in our database queries. If an exception is thrown within the try{ } block,
the script stops executing and flows directly to the first catch(){ } block.

cf. https://www.w3schools.com/php/php_mysql_connect.asp

conclusio: all attemts to set up a mysql-db that
is accessible from a Wordpress-installation failed.

some more ideas that i need to think about.

i should do some more tests and i will try to change "localhost" to "127.0.0.1

see https://www.fatalerrors.org/a/warning-mysqli-mysqli-hy000-2002-no-such-file-or-directory.html

i further have to test [url="

commented: Looks like progress now you have the trailing ?>. +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.