Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><blockquote> <p>Why is this happening?</p> </blockquote> <p>The entire <code>ext/mysql</code> PHP extension, which provides all functions named with the prefix <code>mysql_</code>, was <a href="http://php.net/manual/en/changelog.mysql.php" rel="noreferrer">officially deprecated in PHP v5.5.0</a> and <a href="https://secure.php.net/manual/en/migration70.removed-exts-sapis.php" rel="noreferrer">removed in PHP v7</a>.</p> <p>It was originally introduced in PHP v2.0 (November 1997) for MySQL v3.20, and no new features have been added since 2006. Coupled with the lack of new features are difficulties in maintaining such old code amidst complex security vulnerabilities.</p> <p>The manual has contained warnings against its use in new code since June 2011.</p></li> <li><blockquote> <p>How can I fix it?</p> </blockquote> <p>As the error message suggests, there are two other MySQL extensions that you can consider: <a href="http://php.net/manual/en/book.mysqli.php" rel="noreferrer">MySQLi</a> and <a href="http://php.net/manual/en/ref.pdo-mysql.php" rel="noreferrer">PDO_MySQL</a>, either of which can be used instead of <code>ext/mysql</code>. Both have been in PHP core since v5.0, so if you're using a version that is throwing these deprecation errors then you can almost certainly just start using them right away&mdash;i.e. without any installation effort.</p> <p>They differ slightly, but offer a number of advantages over the old extension including API support for transactions, stored procedures and prepared statements (thereby providing <a href="https://stackoverflow.com/a/60496">the best way</a> to defeat <a href="https://stackoverflow.com/q/332365">SQL injection attacks</a>). PHP developer Ulf Wendel has written <a href="http://blog.ulf-wendel.de/2012/php-mysql-why-to-upgrade-extmysql/" rel="noreferrer">a thorough comparison of the features</a>.</p> <p>Hashphp.org has an <a href="http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers" rel="noreferrer">excellent tutorial on migrating from <code>ext/mysql</code> to PDO</a>.</p></li> <li><blockquote> <p>I understand that it's possible to suppress deprecation errors by setting <code>error_reporting</code> in <code>php.ini</code> to exclude <code>E_DEPRECATED</code>:</p> <pre><code>error_reporting = E_ALL ^ E_DEPRECATED </code></pre> <p>What will happen if I do that?</p> </blockquote> <p>Yes, it is possible to suppress such error messages and continue using the old <code>ext/mysql</code> extension for the time being. But <strong>you really shouldn't do this</strong>&mdash;this is a final warning from the developers that the extension may not be bundled with future versions of PHP (indeed, as already mentioned, it has been removed from PHP v7). Instead, you should take this opportunity to migrate your application <em>now</em>, before it's too late.</p> <p>Note also that this technique will suppress <em>all</em> <code>E_DEPRECATED</code> messages, not just those to do with the <code>ext/mysql</code> extension: therefore you may be unaware of other upcoming changes to PHP that would affect your application code. It is, of course, possible to only suppress errors that arise on the expression at issue by using PHP's <a href="http://php.net/manual/en/language.operators.errorcontrol.php" rel="noreferrer">error control operator</a>&mdash;i.e. prepending the relevant line with <code>@</code>&mdash;however this will suppress <em>all</em> errors raised by that expression, not just <code>E_DEPRECATED</code> ones.</p></li> </ol> <hr> <h3>What should you do?</h3> <ul> <li><p><strong>You are starting a new project.</strong></p> <p>There is <em>absolutely no reason</em> to use <code>ext/mysql</code>&mdash;choose one of the other, more modern, extensions instead and reap the rewards of the benefits they offer.</p></li> <li><p><strong>You have (your own) legacy codebase that currently depends upon <code>ext/mysql</code>.</strong></p> <p>It would be wise to perform regression testing: you really shouldn't be changing <em>anything</em> (especially upgrading PHP) until you have identified all of the potential areas of impact, planned around each of them and then thoroughly tested your solution in a staging environment.</p> <ul> <li><p><strong>Following good coding practice, your application was developed in a loosely integrated/modular fashion and the database access methods are all self-contained in one place that can easily be swapped out for one of the new extensions.</strong></p> <p>Spend half an hour rewriting this module to use one of the other, more modern, extensions; test thoroughly. You can later introduce further refinements to reap the rewards of the benefits they offer.</p></li> <li><p><strong>The database access methods are scattered all over the place and cannot easily be swapped out for one of the new extensions.</strong></p> <p>Consider whether you really need to upgrade to PHP v5.5 at this time.</p> <p>You should begin planning to replace <code>ext/mysql</code> with one of the other, more modern, extensions in order that you can reap the rewards of the benefits they offer; you might also use it as an opportunity to refactor your database access methods into a more modular structure.</p> <p>However, if you have an <em>urgent</em> need to upgrade PHP right away, you might consider suppressing deprecation errors for the time being: but first be sure to identify any other deprecation errors that are also being thrown.</p></li> </ul></li> <li><p><strong>You are using a third party project that depends upon <code>ext/mysql</code>.</strong></p> <p>Consider whether you really need to upgrade to PHP v5.5 at this time.</p> <p>Check whether the developer has released any fixes, workarounds or guidance in relation to this specific issue; or, if not, pressure them to do so by bringing this matter to their attention. If you have an <em>urgent</em> need to upgrade PHP right away, you might consider suppressing deprecation errors for the time being: but first be sure to identify any other deprecation errors that are also being thrown.</p> <p>It is absolutely essential to perform regression testing.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload