Documentation Bug #20743. Added usage of mysql_error() to examples.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@106520 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Sara Golemon 2002-12-02 02:37:29 +00:00
parent 2a72ee6944
commit 39e039f00c
12 changed files with 33 additions and 33 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-affected-rows">
<refnamediv>
@ -58,7 +58,7 @@
<?php
/* connect to database */
mysql_pconnect("localhost", "mysql_user", "mysql_password") or
die ("Could not connect");
die("Could not connect: " . mysql_error());
/* this should return the correct numbers of deleted records */
mysql_query("DELETE FROM mytable WHERE id < 10");
@ -87,7 +87,7 @@ Records deleted: 0
<?php
/* connect to database */
mysql_pconnect("localhost", "mysql_user", "mysql_password") or
die ("Could not connect");
die("Could not connect: " . mysql_error());
/* Update records */
mysql_query("UPDATE mytable SET used=1 WHERE id < 10");

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-close">
<refnamediv>
@ -41,7 +41,7 @@
<![CDATA[
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password")
or exit("Could not connect");
or die("Could not connect: " . mysql_error());
print ("Connected successfully");
mysql_close($link);
?>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-create-db">
<refnamediv>
@ -29,12 +29,12 @@
<![CDATA[
<?php
$link = mysql_pconnect("localhost", "mysql_user", "mysql_password")
or exit("Could not connect");
or die("Could not connect: " . mysql_error());
if (mysql_create_db("my_db")) {
print ("Database created successfully\n");
} else {
printf ("Error creating database: %s\n", mysql_error ());
printf ("Error creating database: %s\n", mysql_error());
}
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-data-seek">
<refnamediv>
@ -40,19 +40,19 @@
<![CDATA[
<?php
$link = mysql_pconnect("localhost", "mysql_user", "mysql_password")
or die("Could not connect");
or die("Could not connect: " . mysql_error());
mysql_select_db("samp_db")
or exit("Could not select database");
or die("Could not select database: " . mysql_error());
$query = "SELECT last_name, first_name FROM friends";
$result = mysql_query($query)
or die("Query failed");
or 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)) {
echo "Cannot seek to row $i\n";
echo "Cannot seek to row $i: " . mysql_error() . "\n";
continue;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.27 -->
<refentry id="function.mysql-fetch-array">
<refnamediv>
@ -69,7 +69,7 @@ select table1.field as foo table2.field as bar from table1, table2
<![CDATA[
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("could not connect");
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
@ -89,7 +89,7 @@ select table1.field as foo table2.field as bar from table1, table2
<![CDATA[
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("could not connect");
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
@ -109,7 +109,7 @@ select table1.field as foo table2.field as bar from table1, table2
<![CDATA[
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("could not connect");
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-fetch-field">
<refnamediv>
@ -97,10 +97,10 @@
<![CDATA[
<?php
mysql_connect('localhost:3306', $user, $password)
or die ("Could not connect");
or die("Could not connect: " . mysql_error());
mysql_select_db("database");
$result = mysql_query("select * from table")
or die("Query failed");
or die("Query failed: " . mysql_error());
/* get column metadata */
$i = 0;
while ($i < mysql_num_fields($result)) {

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-field-name">
<refnamediv>
@ -42,7 +42,7 @@
*/
$link = mysql_connect('localhost', "mysql_user", "mysql_password");
mysql_select_db($dbname, $link)
or die("Could not set $dbname");
or die("Could not set $dbname: " . mysql_error());
$res = mysql_query("select * from users", $link);
echo mysql_field_name($res, 0) . "\n";

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.62 -->
<refentry id="function.mysql-get-host-info">
<refnamediv>
@ -25,7 +25,7 @@
<![CDATA[
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("could not connect");
die("Could not connect: " . mysql_error());
printf ("MySQL host info: %s\n", mysql_get_host_info());
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.62 -->
<refentry id="function.mysql-get-proto-info">
<refnamediv>
@ -25,7 +25,7 @@
<![CDATA[
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("could not connect");
die("Could not connect: " . mysql_error());
printf ("MySQL protocol version: %s\n", mysql_get_proto_info());
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.96 -->
<refentry id="function.mysql-get-server-info">
<refnamediv>
@ -25,7 +25,7 @@
<![CDATA[
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("could not connect");
die("Could not connect: " . mysql_error());
printf ("MySQL server version: %s\n", mysql_get_server_info());
?>
]]>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-insert-id">
<refnamediv>
@ -56,7 +56,7 @@
<![CDATA[
<?php
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("could not connect");
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
mysql_query("INSERT INTO mytable (product) values ('kossu')");

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.62 -->
<refentry id="function.mysql-query">
<refnamediv>
@ -56,7 +56,7 @@
<![CDATA[
<php
$result = mysql_query("SELECT * WHERE 1=1")
or die("Invalid query");
or die("Invalid query: " . mysql_error());
?>
]]>
</programlisting>
@ -73,7 +73,7 @@ $result = mysql_query("SELECT * WHERE 1=1")
<![CDATA[
<?php
$result = mysql_query("SELECT my_col FROM my_tbl")
or die ("Invalid query");
or die("Invalid query: " . mysql_error());
?>
]]>
</programlisting>