<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=PHP_MySQL_to_MySQLi_Changes</id>
	<title>PHP MySQL to MySQLi Changes - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://leo.leung.xyz/wiki/index.php?action=history&amp;feed=atom&amp;title=PHP_MySQL_to_MySQLi_Changes"/>
	<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=PHP_MySQL_to_MySQLi_Changes&amp;action=history"/>
	<updated>2026-11-08T14:02:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=PHP_MySQL_to_MySQLi_Changes&amp;diff=1573&amp;oldid=prev</id>
		<title>Leo: /* Function Name Changes */</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=PHP_MySQL_to_MySQLi_Changes&amp;diff=1573&amp;oldid=prev"/>
		<updated>2016-01-13T19:49:11Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Function Name Changes&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:49, 13 January 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l75&quot;&gt;Line 75:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 75:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| mysql_real_escape_string&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| mysql_real_escape_string&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| mysqli_real_escape_string($link)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| mysqli_real_escape_string($link&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, $string&lt;/ins&gt;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|-&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| mysql_select_db  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;| mysql_select_db  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff:1.41:old-1572:rev-1573:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Leo</name></author>
	</entry>
	<entry>
		<id>https://leo.leung.xyz/wiki/index.php?title=PHP_MySQL_to_MySQLi_Changes&amp;diff=1572&amp;oldid=prev</id>
		<title>Leo: Created page with &quot;With PHP 7 being released, the old MySQL functions such as {{code|mysql_connect}} have been removed. There are a couple ways to connect to MySQL with PHP 7 or higher: {{code|m...&quot;</title>
		<link rel="alternate" type="text/html" href="https://leo.leung.xyz/wiki/index.php?title=PHP_MySQL_to_MySQLi_Changes&amp;diff=1572&amp;oldid=prev"/>
		<updated>2016-01-13T19:46:54Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;With PHP 7 being released, the old MySQL functions such as {{code|mysql_connect}} have been removed. There are a couple ways to connect to MySQL with PHP 7 or higher: {{code|m...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;With PHP 7 being released, the old MySQL functions such as {{code|mysql_connect}} have been removed. There are a couple ways to connect to MySQL with PHP 7 or higher: {{code|mysqli}} or the PDO driver.&lt;br /&gt;
&lt;br /&gt;
The simplest way to fix old scripts is to make use of the {{code|mysqli}} alias/facade functions that provide a familiar procedural interface.&lt;br /&gt;
&lt;br /&gt;
== Function Name Changes ==&lt;br /&gt;
The procedural function wrappers provided by MySQLi is mostly the same as the deprecated functions. The parameters are also similar with the exception that the MySQL connection link must be passed as the first parameter and is not optional.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP 5 or lower&lt;br /&gt;
! PHP 7 or higher&lt;br /&gt;
|-&lt;br /&gt;
| mysql_affected_rows&lt;br /&gt;
| mysqli_affected_rows($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_close&lt;br /&gt;
| mysqli_close($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_data_seek&lt;br /&gt;
| mysqli_data_seek($result, $offset)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_errno&lt;br /&gt;
| mysqli_errno($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_error&lt;br /&gt;
| mysqli_error($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_fetch_array&lt;br /&gt;
| mysqli_fetch_array($result, $type)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_fetch_assoc&lt;br /&gt;
| mysqli_fetch_assoc($result)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_fetch_lengths&lt;br /&gt;
| mysqli_fetch_lengths($result)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_fetch_object&lt;br /&gt;
| mysqli_fetch_object($result, $class, $params)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_fetch_row&lt;br /&gt;
| mysqli_fetch_row($result)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_field_seek&lt;br /&gt;
| mysqli_field_seek($result, $number)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_free_result&lt;br /&gt;
| mysqli_free_result(result)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_get_client_info&lt;br /&gt;
| mysqli_get_client_info($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_get_host_info&lt;br /&gt;
| mysqli_get_host_info($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_get_proto_info&lt;br /&gt;
| mysqli_get_proto_info($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_get_server_info&lt;br /&gt;
| mysqli_get_server_info($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_info&lt;br /&gt;
| mysqli_info($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_insert_id&lt;br /&gt;
| mysqli_insert_id($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_num_rows&lt;br /&gt;
| mysqli_num_rows($result)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_ping&lt;br /&gt;
| mysqli_ping($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_query&lt;br /&gt;
| mysqli_query($link, $query)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_real_escape_string&lt;br /&gt;
| mysqli_real_escape_string($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_select_db &lt;br /&gt;
| mysqli_select_db($link, $database)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_set_charset&lt;br /&gt;
| mysqli_set_charset($link, $charset)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_stat&lt;br /&gt;
| mysqli_stat($link)&lt;br /&gt;
|-&lt;br /&gt;
| mysql_thread_id&lt;br /&gt;
| mysqli_thread_id($link)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width: 50%&amp;quot; | PHP 5 or lower&lt;br /&gt;
! style=&amp;quot;width: 50%&amp;quot; | PHP 7 or higher&lt;br /&gt;
|-&lt;br /&gt;
| {{highlight|lang=php|code=&lt;br /&gt;
$db = mysql_connect(&amp;#039;host&amp;#039;, &amp;#039;user&amp;#039;, &amp;#039;password&amp;#039;) or die (mysql_error());&lt;br /&gt;
mysql_select_db(&amp;#039;database&amp;#039;, $db);&lt;br /&gt;
&lt;br /&gt;
$result = mysql_query(&amp;#039;SELECT * FROM table&amp;#039;, $db);&lt;br /&gt;
&lt;br /&gt;
while ($data = mysql_fetch_array($result)) {&lt;br /&gt;
  echo $data[&amp;#039;field1&amp;#039;] . &amp;quot;\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
mysql_close($db);&lt;br /&gt;
}}&lt;br /&gt;
| {{highlight|lang=php|code=&lt;br /&gt;
$db = mysqli_connect(&amp;#039;host&amp;#039;, &amp;#039;user&amp;#039;, &amp;#039;password&amp;#039;, &amp;#039;database&amp;#039;) or die (mysqli_connect_error($db));&lt;br /&gt;
&lt;br /&gt;
$result = mysql_query($db, &amp;#039;SELECT * FROM table&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
while ($data = mysqli_fetch_array($result)) {&lt;br /&gt;
  echo $data[&amp;#039;field1&amp;#039;] . &amp;quot;\n&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
mysqli_close($db);&lt;br /&gt;
}}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Leo</name></author>
	</entry>
</feed>