11

Which is the latest version PHP version, who support mysql_connect()?

I've want to upgrade my PHP version. I've read, that mysql_connect() are deprecated. In all Projects I've use the old mysql_connect(). Can I update to PHP 5.6.5 or is the command in this version removed already?

Uses somebody PHP 5.6.5 with mysql_connect()?

Problem is, that I can't change sooo much Projects in this short time and could only update to the highest version, which support mysql_connect().

Best regards and many thanks!

Reddi
  • 121
  • 1
  • 1
  • 4
  • 3
    *"Is mysql_connect() usable in PHP 5.6.5"* - **A:** *No'ish,* and [error reporting](http://php.net/manual/en/function.error-reporting.php) will tell you. Use `mysqli_` or PDO. If you get a warning, then you'll have no choice but to switch. – Funk Forty Niner Jan 28 '15 at 21:00
  • 2
    It's still available in 5.6.x, with depreciation notice. In future versions it's likely to become an external PECL module. – mario Jan 28 '15 at 21:02
  • To answer the question at hand, there is a piece of code I remember seeing on Stack/web that will detect whether the functions are deprecated and if so, use the respective API. You just need to look for it. – Funk Forty Niner Jan 28 '15 at 21:13
  • Sorry! I don't find the same question with answer. I've read, that I'll get a deprecation notice. But if I get a notice, then I could use the function?! In future I will/must use the mysqli, but I must take an update now and must use the php version, where mysql_connect() are usuable (notices I can deactivate). But I can't change sooo many codelines to mysqli_* in this short time.... – Reddi Jan 28 '15 at 22:40
  • Instead of just changing it all to mysqli_ directly, create your own database class that uses mysqli_ inside, so when you decide to finally move to PDO you only have to change the internals of that wrapper and not every page's code. – developerwjk Jan 28 '15 at 22:54
  • Now I found my answer in one of the answers of your linked thread (http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). I've don't look at these question, because I thought, this question is still another one and too generally. It seems, that I could use mysql_connect() to 5.7. ;-) – Reddi Jan 28 '15 at 22:55
  • 1
    @developerwjk correct! all new projects uses an own sql class. but the old projects are coded hard and I can't update the server and tomorrow I must change 100 projects with a few thousends codelines... - it isn't possible. therefore I asked in which version the mysql_connect() isn't usable anymore... :-) – Reddi Jan 28 '15 at 22:58

1 Answers1

8

http://php.net/manual/en/function.mysql-connect.php

5.5.0 This function will generate an E_DEPRECATED error.

don't try to use any mysql_* functions as they are deprecated and dangerous. See mysqli_ functions instead.

krzysiej
  • 889
  • 9
  • 22