please help w mysql connection

Hi, I just started a free account hoping to connect to mysql data via php. But I’m having trouble making the connection-- I get the ‘No such file or directory’ error message. My commands should be set correctly in my php ($dbhost = ‘’; $dbuser = ‘xyz’; $dbpass = ‘zyx’; $dbname = ‘abc’;). This all worked fine in a previous environment. Any ideas why not here? Thanks!

What was your previous environment? Was it another hosting account or a local LAMP installation?

Because I have checked your code, but it looks like you’re not calling mysql_connect() at all. You just run a query without setting up a connection, which means PHP uses the default connection details. On a local installation, those details may have been correct by accident.

Right now, you have the settings in variables, but those variables aren’t used anywhere. You need to open a MySQL connection manually with those details.

That said, it’s even better to switch to myqli or PDO instead of the old mysql library, since it’s no longer available in the latest PHP installations.

Thank you! It was a hosted env before (and I just took out the ‘connect’ today when I was messing with it). I updated to mysqli and tried adding ‘user_’ to the db name (now $dbname = ‘xyz_abc’:wink: and it’s working. Thanks so much for your help!