Original MySQL API (
Mysql
)
2242
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');
// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
20.7.2.5. MySQL Functions
Copyright 1997-2012 the PHP Documentation Group. [2230]
Note
Most MySQL functions accept
link_identifier
as the last optional
parameter. If it is not provided, last opened connection is used. If it doesn't exist,
connection is tried to establish with default parameters defined in
php.ini
. If it
is not successful, functions return
FALSE
.
20.7.2.5.1.
mysql_affected_rows
Copyright 1997-2012 the PHP Documentation Group. [2230]
•
mysql_affected_rows
Get number of affected rows in previous MySQL operation
Warning
This extension is deprecated as of PHP 5.5.0, and will be removed in the
future. Instead, the
MySQLi
or
PDO_MySQL
extension should be used. See
also
MySQL: choosing an API
guide and
related FAQ
for more information.
Alternatives to this function include:
mysqli_affected_rows
PDOStatement::rowCount
Description
int mysql_affected_rows(
resource link_identifier
= =NULL);
Get the number of affected rows by the last INSERT, UPDATE, REPLACE or DELETE query
associated with
link_identifier
.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...