Connecting to the SQL database on a free account

Website URL

puzzlemaster.gamer.gd

Error Message

getaddrinfo for sql100.infinityfree.com failed: name or service not known

Other Information

I know I can’t connect from a remote source with a free account, but I’ve set up the connection string to use the information provided by the database information on my account page. Even on phpMyAdmin, the server is listed as the same, but the live website doesn’t recognize the hostname.

How are you trying to connect to the database?

I’ve not seen that error before

1 Like

This should be your error

Cannot redeclare addNewUser() (previously declared in /home/vol1000_8/infinityfree.com/if0_40342379/htdocs/dbConnect.php:15) in
/home/vol1000_8/infinityfree.com/if0_40342379/htdocs/dbConnect.php
on line
15

Check your code

4 Likes

I’m using PDO functionality built into PHP, as follows

$pdo = new PDO(‘mysql:host=sql100.infinityfree.com :3306;dbname=if0_40342379_puzzlemaster’, ‘[username]’, ‘[password]’);

Normally yes, but the only change I’ve made from functional local code is the PDO creation parameters, so unless proven otherwise I’m going to assume it’s a consequence of the fact that the PDO reference doesn’t exist.

Try to remove the :3306 part after the hostname on the host parameter of the DSN and see if it works. Also, make sure there is no extra space before or after the hostname (or new line in your case).

7 Likes

2 potential issues
1 - it might be a formatting issue here, but there shouldn’t be a space between the host and port.
2 - Having checked my own code where I’ve done the same, I didn’t include the port. So maybe try removing it

–edit–
Jxst’s post appeard just as I hit send haha

6 Likes

Removing the port doesn’t even provide an error, just kills the php at the point of the database request. I’ve never seen anything quite like it, tbh.

digging through it, I’m seeing a 404 error in the console from infinityfree, I suppose it’s failing to find the database still?

Hello. I’m actually seeing HTTP 500 error. Is PHP error reporting enabled? There could be a syntax or error in your PHP code. The 404 error is just about favicon.ico.

4 Likes

You’re right, it was an error with a SQL statement as part of a required php file, straightened that out and it works! Appreciate the help!

3 Likes