Solved

PHP cannot connect to MySQL // Connecting to 3.22, 3.23 & 4.0 servers is not supported

Posted on 2013-11-05
9
4,254 Views
Last Modified: 2013-11-06
Hi,

i've got some problems connecting our MySQL Server with PHP.
We are using PHP 5.3.20 ans MySQL 5.5.14

Everytime I try to connect to the mysql server I recieve the error message

"Connecting to 3.22, 3.23 & 4.0 servers is not supported"

As I said, we are running Version 5.5.14, so I can't unterstand whats the problem.

I already deleted and readded the Database and the Databaseuser.
If I switch back the PHP Version to 4.40 everything works fine.

Can somebody please help?
0
Comment
Question by:opticom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39624854
Can you post your PHP script that you use to connect
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39624901
Please show us the complete error message, including the line numbers.  And show us the lines of PHP code.

And don't switch PHP back to Version 4.  PHP 5+ has been current for several years.
0
 

Author Comment

by:opticom
ID: 39625002
That's the only error message i get (with mysql_error)

That's the include code for all pages

<?php

$mysqlhost='xxx.xxx.xxx.xxx';
$mysqluser='frsdf.81';
$mysqlpwd='xxxxx'; 
$mysqldb='fwde';  

$connection = mysql_connect($mysqlhost, $mysqluser, $mysqlpwd) or die (mysql_error()); 

mysql_query("SET NAMES 'utf8'");
mysql_select_db($mysqldb, $connection) or die("Cannot connect database"); 

?>

Open in new window


In thats the way I open the database table in the index.php:

$sql_estz = "SELECT * FROM estz WHERE E_ID=$E_ID";
$estz_query = mysql_query($sql_estz) or die("Error );

Open in new window

0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39625027
It sounds like you have the MySQL driver leftover from PHP 4.4 because that's what causes that error message.  When you install PHP 5.xxx, it should COMPLETELY replace all of the code from PHP 4.4.  When I have upgraded PHP on my Windows machine, I rename the existing directory and put the new code in a different folder.  In addition,  you may have to go into your IIS setup and unclick 'Cache ISAPI applications' which is on the Home Directory tab under Configuration.  Then restart IIS at least once and maybe twice so it will read the new version of PHP.
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 100 total points
ID: 39625116
You need to be stepping away from using the mysql library and switch to either mySQLi or PDO. This is how you'd connect using PDO:

<?php
$mysqlhost='xxx.xxx.xxx.xxx';
$mysqluser='frsdf.81';
$mysqlpwd='xxxxx'; 
$mysqldb='fwde';  

try {
   $dbh = new PDO('mysql:host=$mysqlhost;dbname=$mysqldb', $mysqluser, $mysqlpwd);
} catch (PDOException $e) {
   echo $e->getMessage();
   exit;
}
?>

Open in new window

Ray's written a great article on this here:

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11177-PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 39625216
The MySQLi connection object gives you a lot more information.  It may be necessary for you to reinstall a current version of MySQL (at least temporarily until you can upgrade to MySQLi or PDO).  MySQL is no longer bundled with PHP and has to be installed separately.  This is a change from PHP 4x.
http://php.net/manual/en/mysql.requirements.php
http://php.net/manual/en/mysql.installation.php
0
 

Author Closing Comment

by:opticom
ID: 39627732
Hi,

I changed to MySQLi and everything works great.
No more errors...

Maybe later I'll have a look on PDO - sounds interesting - but at the moment MySQLi solves the problem for me...

Thank you
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39627756
If MySQLi works for you then stick with it. PDO is just an alternative - not necessarily better or worse (although I do like named parameters available in PDO)
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39627784
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question