Please, don't touch other parts of the manual to do this "hack"
didou
Stefan Walk wrote:
et Fri Feb 20 12:36:42 2004 EDT
Modified files: /phpdoc/en/reference/mysql/functions mysql-affected-rows.xml mysql-close.xml mysql-connect.xml mysql-create-db.xml mysql-data-seek.xml mysql-fetch-field.xml mysql-field-name.xml mysql-get-host-info.xml mysql-get-proto-info.xml mysql-get-server-info.xml mysql-insert-id.xml mysql-query.xml mysql-real-escape-string.xml mysql-result.xml mysql-select-db.xml Log:
CS, minor bugs
------------------------------------------------------------------------
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml?r1=1.13&r2=1.14&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml:1.13 phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml:1.14
--- phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml:1.13 Fri Jan 9 18:00:31 2004
+++ phpdoc/en/reference/mysql/functions/mysql-affected-rows.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.13 $ -->
+<!-- $Revision: 1.14 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-affected-rows">
<refnamediv>
@@ -57,16 +57,18 @@
<![CDATA[
<?php
/* connect to database */
-mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
-mysql_select_db("mydb");
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+mysql_select_db('mydb');
/* this should return the correct numbers of deleted records */
-mysql_query("DELETE FROM mytable WHERE id < 10");
-printf("Records deleted: %d\n", mysql_affected_rows());
+mysql_query('DELETE FROM mytable WHERE id < 10');
+printf('Records deleted: %d\n', mysql_affected_rows());
-/* without a where clause in a delete statement, it should return 0 */
-mysql_query("DELETE FROM mytable");
+/* with a where clause that is never true, it should return 0 */
+mysql_query('DELETE FROM mytable WHERE 0');
printf("Records deleted: %d\n", mysql_affected_rows());
?>
]]>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-close.xml?r1=1.6&r2=1.7&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-close.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-close.xml:1.6 phpdoc/en/reference/mysql/functions/mysql-close.xml:1.7
--- phpdoc/en/reference/mysql/functions/mysql-close.xml:1.6 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-close.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-close">
<refnamediv>
@@ -41,9 +41,11 @@
<programlisting role="php">
<![CDATA[
<?php
-$link = mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
-echo "Connected successfully";
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
mysql_close($link);
?>
]]>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-connect.xml?r1=1.11&r2=1.12&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-connect.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-connect.xml:1.11 phpdoc/en/reference/mysql/functions/mysql-connect.xml:1.12
--- phpdoc/en/reference/mysql/functions/mysql-connect.xml:1.11 Tue Jan 6 04:21:00 2004
+++ phpdoc/en/reference/mysql/functions/mysql-connect.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.11 $ -->
+<!-- $Revision: 1.12 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-connect">
<refnamediv>
@@ -95,9 +95,11 @@
<programlisting role="php">
<![CDATA[
<?php
-$link = mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
-echo "Connected successfully";
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
mysql_close($link);
?>
]]>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-create-db.xml?r1=1.9&r2=1.10&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-create-db.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-create-db.xml:1.9 phpdoc/en/reference/mysql/functions/mysql-create-db.xml:1.10
--- phpdoc/en/reference/mysql/functions/mysql-create-db.xml:1.9 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-create-db.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-create-db">
<refnamediv>
@@ -29,13 +29,15 @@
<programlisting role="php">
<![CDATA[
<?php
-$link = mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
-if (mysql_create_db("my_db")) {
+if (mysql_create_db('my_db')) {
echo "Database created successfully\n";
} else {
- echo "Error creating database: " . mysql_error() . "\n";
+ echo 'Error creating database: ' . mysql_error() . "\n";
}
?>
]]>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-data-seek.xml?r1=1.10&r2=1.11&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-data-seek.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-data-seek.xml:1.10 phpdoc/en/reference/mysql/functions/mysql-data-seek.xml:1.11
--- phpdoc/en/reference/mysql/functions/mysql-data-seek.xml:1.10 Wed Jan 28 05:50:53 2004
+++ phpdoc/en/reference/mysql/functions/mysql-data-seek.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.10 $ -->
+<!-- $Revision: 1.11 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-data-seek">
<refnamediv>
@@ -42,16 +42,19 @@
<programlisting role="php">
<![CDATA[
<?php
-$link = mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
-
-mysql_select_db("samp_db")
- or die("Could not select database: " . mysql_error());
-
-$query = "SELECT last_name, first_name FROM friends";
-$result = mysql_query($query)
- or die("Query failed: " . mysql_error());
-
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+$db_selected = mysql_select_db('sample_db');
+if (!$db_selected) {
+ die('Could not select database: ' . mysql_error());
+}
+$query = 'SELECT last_name, first_name FROM friends';
+$result = mysql_query($query);
+if (!$result) {
+ die('Query failed: ' . mysql_error());
+}
/* fetch rows in reverse order */
for ($i = mysql_num_rows($result) - 1; $i >= 0; $i--) {
if (!mysql_data_seek($result, $i)) {
@@ -59,10 +62,11 @@
continue;
}
- if (!($row = mysql_fetch_object($result)))
+ if (!($row = mysql_fetch_assoc($result))) {
continue;
+ }
- echo "$row->last_name $row->first_name<br />\n";
+ echo $row['last_name'] . ' ' . $row['first_name'] . "<br />\n";
}
mysql_free_result($result);
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-fetch-field.xml?r1=1.9&r2=1.10&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-fetch-field.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-fetch-field.xml:1.9 phpdoc/en/reference/mysql/functions/mysql-fetch-field.xml:1.10
--- phpdoc/en/reference/mysql/functions/mysql-fetch-field.xml:1.9 Sun Oct 19 16:55:05 2003
+++ phpdoc/en/reference/mysql/functions/mysql-fetch-field.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-fetch-field">
<refnamediv>
@@ -98,11 +98,15 @@
<programlisting role="php">
<![CDATA[
<?php
-mysql_connect('localhost:3306', $user, $password)
- or die("Could not connect: " . mysql_error());
-mysql_select_db("database");
-$result = mysql_query("select * from table")
- or die("Query failed: " . mysql_error());
+$conn = mysql_connect('localhost:3306', 'user', 'password');
+if (!$conn) {
+ die('Could not connect: ' . mysql_error());
+}
+mysql_select_db('database');
+$result = mysql_query('select * from table');
+if (!$result) {
+ die('Query failed: ' . mysql_error());
+}
/* get column metadata */
$i = 0;
while ($i < mysql_num_fields($result)) {
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-field-name.xml?r1=1.8&r2=1.9&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-field-name.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-field-name.xml:1.8 phpdoc/en/reference/mysql/functions/mysql-field-name.xml:1.9
--- phpdoc/en/reference/mysql/functions/mysql-field-name.xml:1.8 Sun Jul 13 15:29:00 2003
+++ phpdoc/en/reference/mysql/functions/mysql-field-name.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-field-name">
<refnamediv>
@@ -42,11 +42,16 @@
* username
* password.
*/
-$link = mysql_connect('localhost', "mysql_user", "mysql_password");
-$dbname = "mydb";
-mysql_select_db($dbname, $link)
- or die("Could not set $dbname: " . mysql_error());
-$res = mysql_query("select * from users", $link);
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$db_selected) {
+ die('Could not set $dbname: ' . mysql_error());
+}
+$dbname = 'mydb';
+$db_selected = mysql_select_db($dbname, $link);
+if (!$db_selected) {
+ die('Could not set $dbname: ' . mysql_error());
+}
+$res = mysql_query('select * from users', $link);
echo mysql_field_name($res, 0) . "\n";
echo mysql_field_name($res, 2);
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-get-host-info.xml?r1=1.8&r2=1.9&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-get-host-info.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-get-host-info.xml:1.8 phpdoc/en/reference/mysql/functions/mysql-get-host-info.xml:1.9
--- phpdoc/en/reference/mysql/functions/mysql-get-host-info.xml:1.8 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-get-host-info.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.62 -->
<refentry id="function.mysql-get-host-info">
<refnamediv>
@@ -25,8 +25,10 @@
<programlisting role="php">
<![CDATA[
<?php
-mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
printf("MySQL host info: %s\n", mysql_get_host_info());
?>
]]>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-get-proto-info.xml?r1=1.9&r2=1.10&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-get-proto-info.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-get-proto-info.xml:1.9 phpdoc/en/reference/mysql/functions/mysql-get-proto-info.xml:1.10
--- phpdoc/en/reference/mysql/functions/mysql-get-proto-info.xml:1.9 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-get-proto-info.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.62 -->
<refentry id="function.mysql-get-proto-info">
<refnamediv>
@@ -25,8 +25,10 @@
<programlisting role="php">
<![CDATA[
<?php
-mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
printf("MySQL protocol version: %s\n", mysql_get_proto_info());
?>
]]>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-get-server-info.xml?r1=1.8&r2=1.9&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-get-server-info.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-get-server-info.xml:1.8 phpdoc/en/reference/mysql/functions/mysql-get-server-info.xml:1.9
--- phpdoc/en/reference/mysql/functions/mysql-get-server-info.xml:1.8 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-get-server-info.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.8 $ -->
+<!-- $Revision: 1.9 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.96 -->
<refentry id="function.mysql-get-server-info">
<refnamediv>
@@ -25,8 +25,10 @@
<programlisting role="php">
<![CDATA[
<?php
-mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
printf("MySQL server version: %s\n", mysql_get_server_info());
?>
]]>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-insert-id.xml?r1=1.9&r2=1.10&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-insert-id.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-insert-id.xml:1.9 phpdoc/en/reference/mysql/functions/mysql-insert-id.xml:1.10
--- phpdoc/en/reference/mysql/functions/mysql-insert-id.xml:1.9 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-insert-id.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-insert-id">
<refnamediv>
@@ -56,9 +56,11 @@
<programlisting role="php">
<![CDATA[
<?php
-mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
-mysql_select_db("mydb");
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+mysql_select_db('mydb');
mysql_query("INSERT INTO mytable (product) values ('kossu')");
printf("Last inserted record has id %d\n", mysql_insert_id());
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-query.xml?r1=1.9&r2=1.10&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-query.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-query.xml:1.9 phpdoc/en/reference/mysql/functions/mysql-query.xml:1.10
--- phpdoc/en/reference/mysql/functions/mysql-query.xml:1.9 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-query.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.62 -->
<refentry id="function.mysql-query">
<refnamediv>
@@ -47,8 +47,10 @@
<programlisting role="php">
<![CDATA[
<?php
-$result = mysql_query("SELECT * WHERE 1=1")
- or die("Invalid query: " . mysql_error());
+$result = mysql_query('SELECT * WHERE 1=1');
+if (!$result) {
+ die('Invalid query: ' . mysql_error());
+}
?>
]]>
</programlisting>
@@ -64,8 +66,10 @@
<programlisting role="php">
<![CDATA[
<?php
-$result = mysql_query("SELECT my_col FROM my_tbl")
- or die("Invalid query: " . mysql_error());
+$result = mysql_query('SELECT my_col FROM my_tbl');
+if (!$result) {
+ die('Invalid query: ' . mysql_error());
+}
?>
]]>
</programlisting>
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-real-escape-string.xml?r1=1.7&r2=1.8&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-real-escape-string.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-real-escape-string.xml:1.7 phpdoc/en/reference/mysql/functions/mysql-real-escape-string.xml:1.8
--- phpdoc/en/reference/mysql/functions/mysql-real-escape-string.xml:1.7 Mon Jan 12 15:39:39 2004
+++ phpdoc/en/reference/mysql/functions/mysql-real-escape-string.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.7 $ -->
+<!-- $Revision: 1.8 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.100 -->
<refentry id="function.mysql-real-escape-string">
<refnamediv>
@@ -33,8 +33,10 @@
<programlisting role="php">
<![CDATA[
<?php
-$link = mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
$item = "Zak's and Derick's Laptop";
$escaped_item = mysql_real_escape_string($item, $link);
printf("Escaped string: %s\n", $escaped_item);
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-result.xml?r1=1.6&r2=1.7&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-result.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-result.xml:1.6 phpdoc/en/reference/mysql/functions/mysql-result.xml:1.7
--- phpdoc/en/reference/mysql/functions/mysql-result.xml:1.6 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-result.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-result">
<refnamediv>
@@ -43,12 +43,14 @@
<programlisting role="php">
<![CDATA[
<?php
-$link = mysql_connect("localhost", "mysql_user", "mysql_password")
- or die("Could not connect: " . mysql_error());
-
-$result = mysql_query("SELECT name FROM work.employee")
- or die("Could not query:" . mysql_error());
-
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+$result = mysql_query('SELECT name FROM work.employee');
+if (!$result) {
+ die('Could not query:' . mysql_error());
+}
echo mysql_result($result, 2); // outputs third employee's name
mysql_close($link);
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-select-db.xml?r1=1.6&r2=1.7&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-select-db.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-select-db.xml:1.6 phpdoc/en/reference/mysql/functions/mysql-select-db.xml:1.7
--- phpdoc/en/reference/mysql/functions/mysql-select-db.xml:1.6 Mon Jan 5 08:03:26 2004
+++ phpdoc/en/reference/mysql/functions/mysql-select-db.xml Fri Feb 20 12:36:42 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.6 $ -->
+<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-select-db">
<refnamediv>
@@ -37,12 +37,16 @@
<![CDATA[
<?php
-$link = mysql_connect('localhost', 'mysql_user', 'mysql_password')
- or die('Not connected : ' . mysql_error());
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Not connected : ' . mysql_error());
+}
// make foo the current db
-mysql_select_db('foo', $link) or die ('Can\'t use foo : ' . mysql_error());
-
+$db_selected = mysql_select_db('foo', $link);
+if (!$db_selected) {
+ die ('Can\'t use foo : ' . mysql_error());
+}
?>
]]>
</programlisting>