PDA

View Full Version : PHP not working with MySQL


TurboWebs
10-27-2005, 03:44 PM
New server with PHP and MySQL.

MySQL is working fine. I checked and double checked. Tables are in place, queries are all working from the command line, user permissions setup, Log file shows it's ready for connections

PHP first wouldn't even try to connect, didn't have the MySQL extension installed. Installed it. Now I am recieving "Connection to database failed". Double checked config for php script has all the correct connection settings that work from the command line. Double checked that they work from the command line. Still cannot connect to database.

Any ideas for the guy riding the short bus?

TurboWebs
10-27-2005, 05:12 PM
I don't know how to double check but it looks like I am running the regular mysql mod, but for MySQL 4.1+ I have to use mysqli.

What I am having trouble figuring out now is should I use the mysqli? Better password encryption, but I don't understand the differnet commands. Does that mean I have to change the php scripts that access the DB? like instead of mysql_connect() I would have to use mysqli_connect().

There is a whole list of commands for the mysqli but I didn't understand if that was needed in the PHP scripts or that was something else. Maybe I should just play it safe and get 4.1 to use old-passwords

TurboWebs
10-27-2005, 05:38 PM
Nope that wasn't it. I configured MySQL passwords with OLD_PASSWORD and restarted with the --old-passwords option but that was a no go. Still same problems.

Anyone else have any ideas?

I appreciate all the responses so far :)

Eric
10-27-2005, 06:35 PM
You don't need mysqli. Log in to mysql, use mysql, then
UPDATE user SET Password=OLD_PASSWORD('mypass') WHERE User='root';

Then

FLUSH PRIVILEGES;

Your done

TurboWebs
10-27-2005, 07:24 PM
Yeah I tried that but it didn't work. Then I also read that you needed to start MySQL with the --old-passwords option so that MySQL would parse with old password hash. But that didn't work either, so I put it all back to the standard.

You know since being on a dedicated server (one day). I've really grown to appreciate a VDS.

TurboWebs
10-27-2005, 10:14 PM
Someone replied to me with this on another forum. What is the thought from you guys?

Hi,

Thought I'd contribute my two cents. PHP 4.X.X has built in (no .dll needed) connectivity to MySQL.

Regretfully, my experience has been that PHP 4.X.X. has a very out of date, built-in MySQL client, that actually does not communicate at all with the MySQL 4.X.14.

So I believe that you have a version mismatch.

Actaully, I've found that you can either get a hold of an older veriosn of MySQL and load that on the computer and get it to work. Unfortunately, older versions come with their built-in bugs.

Alternatively, use PHP 5.0 to communicate with MySQL 4.X.X and that definitely works cause I use it.

I also use PHP 5.X with MySQL 5.X.X. quite successfully.

If anyone needs details of how to get PHP5 and MySQL5 to connect do reply to this post.