Jump to content

Lasslos05

New Members
  • Posts

    7
  • Joined

  • Last visited

Lasslos05's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey Guys, its me again. Long story short: It wasn't the solution. It seemed to be it, but only because the output of ->connect_error is a string and cannot be used in an if, statement. I found the real solution, however. Here is a part of an email i wrote to my provider: 1. quoting from their article: "Please pay attention to the capitalization of the letters "DB" when specifying the database name. A connect using "dbxxxx" will fail.". This is wrong. In fact, any access made with uppercase letters will fail. These letters must be lowercase. 2. your example script uses the mysql_connect() command. This is deprecated since PHP 5.0 and has been removed in PHP 7.0. Therefore it does not work. Please change it to mysqli_connect, mysql or PDO(). 3. your article always says that the user would be something like Uxxxxxx, and the database something like DBxxxxxxxx. This is wrong. In fact, the database is something like dbsXXXXXXX, and the user name is dbuXXXXXX. Translated with www.DeepL.com/Translator (free version). That is why it didn't work. Also, yes, mysql driver is installed.
  2. I don't know how, but I solved it. I just tried a random script from the internet that looked a little bit different. It's that one: <?php $user = 'DBu*******'; $pass = '****************'; $host = 'rdbms.strato.de'; $db = 'DBs**********'; $conn = new mysqli($host, $user, $pass, $dbdb); if ($conn->connect_error) { echo("Connection failed: " . $conn->connect_error); } else { echo "Success"; } ?> Thanks so much to all of you who tried to help me.
  3. And btw, I tried to change the PHP Version to 8.0. Now it says SQLSTATE[HY000] [2002] No such file or directory I obviously can change it back but I would appreciate if someone knew a new way in PHP 8.0, mabye that will solve the problem.
  4. Hey Guys, first of all, thank you for the reply's. I taught I would be subscribed to that topic automatically. Apparently, I wasn't. I ran the code of @gizmola exactly how he wrote it except for the error thrown in the catch block, and replaced it with echo $e->getMessage(); I have a good message and a bad message: Good message: It shows something different! Bad message: It's an error. The error is: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) And if I try it with SSH, as @kicken suggested, it throws: ERROR 2003: (HY000): Can't connect to MySQL server on 'rdbms.webmailer.de' (113) I've tried it twice, and I'm pretty sure there was no typo. I could not find any security settings that could block access.
  5. I don't think so. The tutorial from my hosting service (strato.de) uses mysql_connect($db_server, $db_user, $db_password). If there is a port added automatically when using mysql_, then that could be the issue. The code from the offical tutorial from strato: # Access data $db_server = 'rdbms.strato.de'; $db_user = ''; $db_passwort = ''; $db_name = ''; # Connection establishment if(mysql_connect($db_server, $db_user, $db_password)) { echo 'Server connection successful, select database... '; if(mysql_select_db($db_name)) { echo 'Server connection successful, select database ... } else { echo 'The specified database could not be selected, please check the information you have entered!'; } } else { echo 'Connection not possible, please check data! '; echo 'MYSQL-error: '.mysql_error(); } ?>
  6. Thanks for the reply. I changed the code: <?php $host = 'rdbms.strato.de'; $db = 'DBS*********'; $user = 'DBU******'; $password = '******************'; $dsn = "mysql:host=$host;dbname=$db;charset=UTF8"; try { $db = new PDO($dsn, $user, $password); echo 'connected'; } catch (PDOException $e) { echo $e->getMessage(); } ?> It still doesn't work. Is there something else wrong? I'm pretty sure the login data is correct. Error Message: SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'rdbms.webmailer.de' (113)
  7. Hey Guys, I'm building my own website with flutter. It needs a database, so I set up one on strato.de and tried to set up a php connection. See here: db.lh0.eu/db_connection.php The code: <?php $db_server = 'rdbms.strato.de'; $db_benutzer = 'DBU******'; $db_passwort = '******************'; $db_name = 'DBS********'; # Verbindungsaufbau if(mysql_connect($db_server, $db_benutzer, $db_passwort)) { echo 'Server-Verbindung erfolgreich, wähle Datenbank aus...'; if(mysql_select_db($db_name)) { echo 'Datenbank erfolgreich ausgewält, alle Tests abgeschlossen.'; } else { echo 'Die angegebene Datenbank konnte nicht ausgewählt werden, bitte die Eingabe prüfen!'; } } else { echo 'Verbindung nicht möglich, bitte Daten prüfen! '; echo 'MYSQL-Fehler: '.mysql_error(); } ?> Anything I did wrong? The documentation how to use PHP to access the database is here: https://www.strato-hosting.co.uk/faq/hosting/this-is-how-you-can-use-our-mysql-database/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.