Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
April 23, 2014, 03:46:41 PM

Pages: [1] 2   Go Down
  Print  
Author Topic: Can't run MYSQLi on LP  (Read 6519 times)
fates66
Intergalactic Cowboy
*****
Offline Offline

Posts: 61


« on: August 09, 2013, 02:43:58 AM »

I updated  accessing database from the old MYSQL to newer one MYSQLi on LP. I got the following errors,

Warning: mysqli_connect() [function.mysqli-connect]: Premature end of data (mysqlnd_wireprotocol.c:553) in /home/ez2gr2/public_html/oc/ErPer/test.php on line 2

Warning: mysqli_connect() [function.mysqli-connect]: OK packet 1 bytes shorter than expected in /home/ez2gr2/public_html/oc/ErPer/test.php on line 2

Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2000): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in /home/ez2gr2/public_html/oc/ErPer/test.php on line 2

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/ez2gr2/public_html/oc/ErPer/test.php on line 5

Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, null given in /home/ez2gr2/public_html/oc/ErPer/test.php on line 8

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, null given in /home/ez2gr2/public_html/oc/ErPer/test.php on line 9
- --->

Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, null given in /home/ez2gr2/public_html/oc/ErPer/test.php on line 12

Warning: mysqli_close() expects parameter 1 to be mysqli, boolean given in /home/ez2gr2/public_html/oc/ErPer/test.php on line 13

And the code as,
 
Code:
<?php
    $link 
mysqli_connect("localhost"userpassword,dbName);
    
$query "SELECT * FROM tables";

    
$result mysqli_query($link$query);
    
    if (
$numRows mysqli_num_rows) {
$row mysqli_fetch_row($result);
$fields mysqli_num_fields($result);
echo $row[0] . "-" $row['id'] . " ---> " $fields "<br>";
}
mysqli_free_result$result );
mysqli_close($link);
?>


I have no access to run the command as,

SET PASSWORD = PASSWORD('your_existing_password')


So how to fix the above problems. Any comments will be appreciated.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5811



« Reply #1 on: August 09, 2013, 05:24:18 AM »

Are you running PHP 5 or are you still on PHP 4 for some reason? I'm not sure PHP 4 supports MySQLi. If that doesn't do it, and no one else answers within a day or two, I would open a support ticket to ask what's going on. Possibly your server wasn't set up correctly (ask them to check that MySQLi was added to PHP).
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
fates66
Intergalactic Cowboy
*****
Offline Offline

Posts: 61


« Reply #2 on: August 09, 2013, 06:05:11 AM »

Thanks MrPhil. I have checked my server environment : Apache version is 1.3.42, PHP version is 5.3.24 and the MySQL is 5.5.30-cl. I also run that on Pandora server of LP with Apache version 2.2.24 and it work. I don't know why. Any comments?
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5811



« Reply #3 on: August 10, 2013, 04:38:58 AM »

Apache 1.3 is positively ancient. Maybe that server is scheduled to be updated? I don't know if the Apache level has anything to do with MySQLi (I think PHP level does). I would open a ticket and see if MySQLi is supposed to be available on that server, and if not, was it an oversight or is it scheduled to be installed? If you need MySQLi and your server won't have it any time soon, you may have to ask about being moved to a server that does have it.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
fates66
Intergalactic Cowboy
*****
Offline Offline

Posts: 61


« Reply #4 on: August 10, 2013, 06:07:08 PM »

Just add the following two lines to .htaccess and place it in the same folder as php file. It should work!

AddHandler application/x-httpd-php52 .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php52 .php5 .php4 .php .php3 .php2 .phtml 
Logged
gbbou3
Newbie
*
Offline Offline

Posts: 1


« Reply #5 on: August 19, 2013, 08:01:59 AM »

Just add the following two lines to .htaccess and place it in the same folder as php file. It should work!

AddHandler application/x-httpd-php52 .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php52 .php5 .php4 .php .php3 .php2 .phtml 

I am also having this problem.  Tried adding that line to .htaccess and it did not fix the problem.  Any other suggestions?
Logged
fates66
Intergalactic Cowboy
*****
Offline Offline

Posts: 61


« Reply #6 on: August 19, 2013, 07:40:20 PM »

Could you show me error message on the responsed? Here are my configurations as follows,
PHP version   5.3.27
MySQL version   5.5.32-cll
Apache version   2.0.64
Logged
dknife
Trekkie
**
Offline Offline

Posts: 15


« Reply #7 on: November 25, 2013, 08:47:59 AM »

I had this problem 6 months ago when I moved to PHP 5.3 and an updated MySQL in my server with LP. The .htaccess method works however it forces PHP 5.2 compatibility, which is not even supported anymore.

I'm now moving to a new forum system and new code base and I must have PHP 5.3 with MySQLi using the built-in mysqlnd connection sequences of PHP 5.3

Support doesn't seem to be much help other than telling me I have to use the 5.2 workaround. I had this strange response awhile ago for this but didn't really understand it since PHP 5.3 uses mysqli native.

Quote
I have reviewed several files and noticed that you are using MySQLi within as a database driver instead of MySQL. While MySQLi works perfectly with PHP 5.2 and the current MySQL version which was upgraded recently it does not work properly with PHP 5.3 and the current MySQL version which is why to correct such issues the code needs to be either redone to use MySQL driver instead of MySQLi and work properly with PHP 5.3 or the PHP version maintained at 5.2.

The Mysql user system on LP Cpanel creates users with the OLD password hashing and you can't update the users to the "new" version (that has been around for years now) without supplying support your connection scripts. Their cpanel doesn't even allow changing of passwords for mysql users as it never accepts the old password.

Is anyone actually using Lunarpages effectively on PHP 5.3+ and MySQL 5.5+ (which are the versions installed on my server)
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5811



« Reply #8 on: November 25, 2013, 09:51:28 AM »

MySQLi is the latest and greatest interface to the MySQL database, and certainly should work well with PHP 5.3 and even PHP 5.2 (maybe not PHP 4.x).

If your .htaccess is "forcing" PHP 5.2, remove or comment out the lines doing that (x-httpd-php52), and I think you have to have lines in there for PHP 5.3 (same lines, just x-httpd-php53). Maybe you added the PHP 5.2 lines after the PHP 5.3 lines?

Dunno about the password issue. See if cleaning up the above issue helps at all. Don't be surprised if it doesn't, as cPanel and (maybe) phpMyAdmin are independent of the PHP level in use.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
dknife
Trekkie
**
Offline Offline

Posts: 15


« Reply #9 on: November 25, 2013, 10:17:48 AM »

MrPhil the problem is that LP doesn't seem to support it correctly. From support:

Quote
I have reviewed several files and noticed that you are using MySQLi within as a database driver instead of MySQL. While MySQLi works perfectly with PHP 5.2 and the current MySQL version which was upgraded recently it does not work properly with PHP 5.3 and the current MySQL version which is why to correct such issues the code needs to be either redone to use MySQL driver instead of MySQLi and work properly with PHP 5.3 or the PHP version maintained at 5.2.
Please note that the code worked previously with PHP 5.3 because both the PHP and MySQL versions were older and compatible.

They (LP) forced my sites previously to 5.2 to make them work with MySQLi, despite it being the native 5.3 interface. So since I'm moving to a new forum system and building new sites requiring 5.3 functions, it doesn't look like I'll be able to stay with LP.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5811



« Reply #10 on: November 25, 2013, 10:40:28 AM »

Well, support is wrong if they're telling you that PHP 5.3 in general doesn't support the MySQLi interface. If they chose to not implement/install it for some reason on LP's servers, that would be a very non-standard installation and very bad news. If it's broken (but should be working) on the servers, they should get it fixed pronto and tell customers that any workaround is needed only temporarily. I suggest that you go back to them and present them with the facts.

MySQL is a very old and very out of date interface to the MySQL database system, and has not been updated since PHP 4.4. MySQLi has been around since PHP 5.0 and is current and maintained.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
dknife
Trekkie
**
Offline Offline

Posts: 15


« Reply #11 on: November 25, 2013, 10:58:10 AM »

It's worse than that MrPhil. You can't create a MySQL user on the LP CPanel with a modern hash algorithm than PHP 5.3 MySQLi can connect to, thus the force by them to 5.2. For example, this process is broken on LP:

  • Create Database
  • Create user and assign to database with full rights
  • Use built-in Softaculous to install phpBB3
  • Run phpBB3 installer and specify login details you created
  • ERROR

Quote
mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords

They can't even provide support for their own products in their own system with their configuration. AND you can't even change an existing mysql user password in CPanel as it always states the old password is incorrect.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5811



« Reply #12 on: November 25, 2013, 11:37:20 AM »

That sounds nasty. Please open a ticket for the phpMyAdmin/cPanel/LPCP problem you're describing, if you haven't done so already. You're sure your .htaccess is specifying PHP 5.3 and isn't still specifying 5.2? cPanel and LPCP should be supporting PHP 5.3 password hashes. Agreed it will be a problem if a customer needs to bounce back and forth between PHP 5.3 and earlier versions, but then, PHP is famous for breaking backwards compatibility. I don't know what's supposed to be done with all existing passwords (manually changed, or what). Presumably this is only the defined database 'users' (one or two per application) and not all your forum members. Please keep us informed on what support does and says.
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
dknife
Trekkie
**
Offline Offline

Posts: 15


« Reply #13 on: November 25, 2013, 04:23:32 PM »

I've already spoken to them and currently their CPanel doesn't allow password changes and won't create "modern" hash passwords (ever since mysql 4.1 guys!?). There's nothing that can be done other than have them re-hash the password manually themselves. Doesn't affect forum users or anything, just mysql users so it's not exactly high impact, just very annoying. However it also breaks half their automated software and leaves users wondering what is going on if they aren't aware of it.
Logged
MrPhil
Senior Moderator
Berserker Poster
*****
Offline Offline

Posts: 5811



« Reply #14 on: November 25, 2013, 04:44:46 PM »

Sigh. Lovely, just lovely. Surely the providers of cPanel, LPCP (Lunarpages), phpMyAdmin, etc. provided a clean and relatively painless way to upgrade database users when going to PHP 5.3? Didn't they?
Logged

Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-
Pages: [1] 2   Go Up
  Print  
 
Jump to: