[drupal-devel] [bug] cannot connect to DB

beginner drupal-devel at drupal.org
Sat Sep 10 07:17:59 UTC 2005


Issue status update for 
http://drupal.org/node/30761
Post a follow up: 
http://drupal.org/project/comments/add/30761

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     bug reports
 Priority:     normal
 Assigned to:  Anonymous
 Reported by:  beginner
 Updated by:   beginner
-Status:       active
+Status:       patch (code needs work)

I've seen that the list of requirements states php > 4.3.0, but I guess
I won't be the only one to be surprised to see that drupal doesn't work
AT ALL (no DB connection) when they upgrade.


Yet, by modifying the line above, to make it look like version 4.6, I
am able to use drupal cvs on my server with an older php version (I'm
on the lookout for other similar bugs).


I was trying to add a if loop, checking on the php version used, so
that we have:



<?php
if ($php_version >= 4.3.0){
  $connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2);
}else{
  $connection = mysql_connect($url['host'], $url['user'], $url['pass'], TRUE) or die(mysql_error());
}
?>




but I cannot find in the documentation how this variable can be tested.


Also, once connected to the data base, a warning in admin/settings can
be added about the php version used.


Or do you really mean to shut out all the people who depend on the
(lack of) will of their host to upgrade php? If so, at the very least,
add a list item in the error message to remind people to check for the
php version.


B.




beginner



Previous comments:
------------------------------------------------------------------------

Fri, 09 Sep 2005 09:11:51 +0000 : beginner

Hello,


I just downloaded and installed the cvs version. It works on my local
system, but it doesn't on the remote host. I checked dozens of time the
settings.php password, db, etc...
Drupal 4.6 works perfectly at the same host, using the same data base,
same user, same password (different prefix only, and different
url/domain).


I get an empty string as sql error message:
The MySQL error was: .


"Are you sure you have the correct username and password?


"
Yes. the same as existing drupal 4.6 install.


"Are you sure that you have typed the correct hostname?


"
Yes. idem.


"Are you sure that the database server is running?


"
Yes. working  for other installation.


To check that the settings.php was properly uploaded, I changed the
username in settings.php and uploaded again: the name changed in the
mention at the bottom of the new error page, but the mysql error is
still an empty string.


I do have a mysql error message if I change the username on my
localhost:
The MySQL error was: Access denied for user: 'testerror at localhost'
(Using password: YES).
Currently, the username is testerror and the database server is
localhost.


????




------------------------------------------------------------------------

Fri, 09 Sep 2005 09:58:29 +0000 : beginner

If I suppress the @ I have the following error message:


Warning: Wrong parameter count for mysql_connect() in 
.../includes/database.mysql.inc on line 37


which seems strange in this context.
I have a - in the database host: out-data.org. Would that affect the
parsing of the variable in settings.php?




------------------------------------------------------------------------

Fri, 09 Sep 2005 11:26:00 +0000 : beginner

It's definitely a php problem, not mysql settings:
we use PHP Version 4.2.3


by replacing the line:

<?php
$connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2);
?>


by its values:

<?php
$connection = mysql_connect('data.out-data.org', 'user', 'pass', TRUE, 2);
?>




I still get the Wrong parameter count for mysql_connect() message...


???


4.6 works fine on the same host.




------------------------------------------------------------------------

Fri, 09 Sep 2005 13:45:29 +0000 : beginner

Drupal 4.6:

<?php
  $connection = mysql_connect($url['host'], $url['user'], $url['pass'], TRUE) or die(mysql_error());
?>




Drupal cvs:

<?php
$connection = @mysql_connect($url['host'], $url['user'], $url['pass'], TRUE, 2);
?>




One more parameter has been added.


php.net/mysql_connect :
php 4.3.0   Added the client_flags parameter.


i.e. cvs Drupal and the coming 4.7 version will not work for php
versions < 4.3.0. My hosts unfortunately uses 4.2.3.







More information about the drupal-devel mailing list