[PHP-DOC] cvs: phpdoc /it/functions mysql.xml From: Luca Perugini (l.perugini <email protected>)
Date: 09/14/00

perugini Thu Sep 14 15:49:08 2000 EDT

  Modified files:
    /phpdoc/it/functions mysql.xml
  Log:
  Sync with en tree.
  
  
Index: phpdoc/it/functions/mysql.xml
diff -u phpdoc/it/functions/mysql.xml:1.5 phpdoc/it/functions/mysql.xml:1.6
--- phpdoc/it/functions/mysql.xml:1.5 Wed Jul 12 02:06:10 2000
+++ phpdoc/it/functions/mysql.xml Thu Sep 14 15:49:08 2000
@@ -3,12 +3,28 @@
   <titleabbrev>MySQL</titleabbrev>
   <partintro>
    <simpara>
- These functions allow you to access MySQL database servers.
+ These functions allow you to access MySQL database servers. In
+ order to have these functions available, you must compile php
+ with mysql support by using the
+ <option role="configure">--with-mysql</option> option. If you
+ use this option without specifying the path to mysql, php will
+ use the built-in mysql client libraries. Users who run other
+ applications that use mysql (for example, running php3 and php4
+ as concurrent apache modules, or auth-mysql) should always
+ specify the path to mysql:
+ <option role="configure">--with-mysql=/path/to/mysql</option>.
+ This will force php to use the client libraries installed by
+ mysql, avoiding any conflicts.
    </simpara>
    <simpara>
     More information about MySQL can be found at <ulink
     url="&url.mysql;">&url.mysql;</ulink>.
    </simpara>
+ <simpara>
+ Documentation for MySQL can be found at <ulink
+ url="&url.mysql.docs;">&url.mysql.docs;</ulink>.
+ </simpara>
+
   </partintro>
 
   <refentry id="function.mysql-affected-rows">
@@ -52,7 +68,7 @@
    <refnamediv>
     <refname>mysql_change_user</refname>
     <refpurpose>
- Change logged in user on active connection
+ Change logged in user of the active connection
     </refpurpose>
    </refnamediv>
    <refsect1>
@@ -76,11 +92,11 @@
     </funcsynopsis>
     <para>
      <function>mysql_change_user</function> changes the logged in user
- on the current active connection, or, if specified on the
- connection given by the link identifier. If a database is
+ of the current active connection, or the connection given by the
+ optional parameter link_identifier. If a database is
      specified, this will default or current database after the user
- has been changed. If the new user/password combination fails to
- be authorized the current connected user stays active.</para>
+ has been changed. If the new user and password authorization fails,
+ the current connected user stays active.</para>
      <note><para>This function was introduced in PHP 3.0.13 and
      requires MySQL 3.23.3 or higher.
     </para></note>
@@ -90,7 +106,7 @@
   <refentry id="function.mysql-close">
    <refnamediv>
     <refname>mysql_close</refname>
- <refpurpose>close MySQL connection</refpurpose>
+ <refpurpose>Close MySQL connection</refpurpose>
    </refnamediv>
    <refsect1>
     <title>Description</title>
@@ -107,21 +123,22 @@
     <para>
      Returns: true on success, false on error.
     </para>
- <para>
- <function>mysql_close</function> closes the link to a MySQL
- database that's associated with the specified link identifier.
- If the link identifier isn't specified, the last opened link is
- assumed.
- </para>
- <note><para>
- This isn't usually necessary, as non-persistent open
- links are automatically closed at the end of the script's
- execution.
- </para></note>
- <para>
- <function>mysql_close</function> will not close persistent links
- generated by <function>mysql_pconnect</function>.
- </para>
+ <para> <function>mysql_close</function> closes the connection to
+ the MySQL server that's associated with the specified link
+ identifier. If <parameter>link_identifier</parameter> isn't
+ specified, the last opened link is used.
+ </para>
+ <para>
+ Using <function>mysql_close</function> isn't usually necessary,
+ as non-persistent open links are automatically closed at the end
+ of the script's execution.
+ </para>
+ <note>
+ <para>
+ <function>mysql_close</function> will not close persistent links
+ created by <function>mysql_pconnect</function>.
+ </para>
+ </note>
     <example>
      <title>MySQL close example</title>
      <programlisting role="php">
@@ -171,15 +188,17 @@
      </funcprototype>
     </funcsynopsis>
     <para>
- Returns: A positive MySQL link identifier on success, or an error
+ Returns a positive MySQL link identifier on success, or an error
      message on failure.
     </para>
- <para>
- <function>mysql_connect</function> establishes a connection to a
- MySQL server. All of the arguments are optional, and if they're
- missing, defaults are assumed ('localhost', user name of the user
- that owns the server process, empty password).
- </para>
+ <para>
+ <function>mysql_connect</function> establishes a connection
+ to a MySQL server. The following defaults are assumed for
+ missing optional parameters: <parameter>host:port</parameter> =
+ 'localhost:3306', <parameter>username</parameter> = name of the
+ user that owns the server process and
+ <parameter>password</parameter> = empty password.
+ </para>
     <para>
      The hostname string can also include a port
      number. eg. &quot;hostname:port&quot; or a path to a socket
@@ -199,10 +218,10 @@
      </note>
     </para>
     <para>
- In case a second call is made to
- <function>mysql_connect</function> with the same arguments, no
- new link will be established, but instead, the link identifier of
- the already opened link will be returned.
+ If a second call is made to <function>mysql_connect</function>
+ with the same arguments, no new link will be established, but
+ instead, the link identifier of the already opened link will be
+ returned.
     </para>
     <para>
      The link to the server will be closed as soon as the execution of
@@ -336,10 +355,71 @@
    </refsect1>
   </refentry>
 
+ <refentry id="function.mysql-db-name">
+ <refnamediv>
+ <refname>mysql_db_name</refname>
+ <refpurpose>Get result data</refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>mysql_db_name</function></funcdef>
+ <paramdef>int <parameter>result</parameter></paramdef>
+ <paramdef>int <parameter>row</parameter></paramdef>
+ <paramdef>mixed
+ <parameter>
+ <optional>field</optional>
+ </parameter>
+ </paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>mysql_db_name</function> takes as its first parameter
+ the result pointer from a call to
+ <function>mysql_list_dbs</function>. The
+ <parameter>row</parameter> parameter is an index into the result
+ set.
+ </para>
+
+ <para>
+ If an error occurs, FALSE is returned. Use
+ <function>mysql_errno</function> and
+ <function>mysql_error</function> to determine the nature of the
+ error.
+ </para>
+
+ <example>
+ <title><function>Mysql_db_name</function> example</title>
+ <programlisting role="php">
+&lt;?php
+error_reporting(E_ALL);
+
+mysql_connect('dbhost', 'username', 'password');
+$db_list = mysql_list_dbs();
+
+$i = 0;
+$cnt = mysql_numrows($db_list);
+while ($i < $cnt) {
+ echo mysql_db_name($db_list, $i) . "\n";
+ $i++;
+}
+?>
+ </programlisting>
+ </example>
+
+ <para>
+ For backward compatibility, <function>mysql_dbname</function> is
+ also accepted. This is deprecated, however.
+ </para>
+
+ </refsect1>
+ </refentry>
+
   <refentry id="function.mysql-db-query">
    <refnamediv>
     <refname>mysql_db_query</refname>
- <refpurpose>Send an MySQL query to MySQL</refpurpose>
+ <refpurpose>Send a MySQL query</refpurpose>
    </refnamediv>
    <refsect1>
     <title>Description</title>
@@ -413,7 +493,7 @@
   <refentry id="function.mysql-errno">
    <refnamediv>
     <refname>mysql_errno</refname>
- <refpurpose>Returns the number of the error message from previous
+ <refpurpose>Returns the numerical value of the error message from previous
      MySQL operation</refpurpose>
    </refnamediv>
    <refsect1>
@@ -429,9 +509,18 @@
      </funcprototype>
     </funcsynopsis>
     <para>
+ Returns the error number from the last mySQL function, or
+ <literal>0</literal> (zero) if no error occurred.
+ </para>
+ <para>
      Errors coming back from the mySQL database backend no longer
- issue warnings. Instead, use these functions to retrieve the
- error number.
+ issue warnings. Instead, use <function>mysql_errno</function> to
+ retrieve the error code. Note that this function only returns the
+ error code from the most recently executed mySQL function (not
+ including <function>mysql_error</function> and
+ <function>mysql_errno</function>), so if you want to use it,
+ make sure you check the value before calling another mySQL
+ function.
      <informalexample>
       <programlisting role="php">
 &lt;?php
@@ -470,9 +559,17 @@
      </funcprototype>
     </funcsynopsis>
     <para>
+ Returns the error text from the last mySQL function, or
+ <literal>''</literal> (the empty string) if no error occurred.
+ </para>
+ <para>
      Errors coming back from the mySQL database backend no longer
- issue warnings. Instead, use these functions to retrieve the
- error string.
+ issue warnings. Instead, use <function>mysql_error</function> to
+ retrieve the error text. Note that this function only returns the
+ error text from the most recently executed mySQL function (not
+ including <function>mysql_error</function> and
+ <function>mysql_errno</function>), so if you want to use it, make
+ sure you check the value before calling another mySQL function.
      <informalexample>
       <programlisting role="php">
 &lt;?php
@@ -669,25 +766,25 @@
     or die ("Query failed");
 # get column metadata
 $i = 0;
-while ($i $lt; mysql_num_fields ($result)) {
+while ($i &lt; mysql_num_fields ($result)) {
     echo "Information for column $i:&lt;BR>\n";
     $meta = mysql_fetch_field ($result);
     if (!$meta) {
         echo "No information available&lt;BR>\n";
     }
     echo "&lt;PRE>
-blob: $meta -> blob
-max_length: $meta -> max_length
-multiple_key: $meta -> multiple_key
-name: $meta -> name
-not_null: $meta -> not_null
-numeric: $meta -> numeric
-primary_key: $meta -> primary_key
-table: $meta -> table
-type: $meta -> type
-unique_key: $meta -> unique_key
-unsigned: $meta -> unsigned
-zerofill: $meta -> zerofill
+blob: $meta->blob
+max_length: $meta->max_length
+multiple_key: $meta->multiple_key
+name: $meta->name
+not_null: $meta->not_null
+numeric: $meta->numeric
+primary_key: $meta->primary_key
+table: $meta->table
+type: $meta->type
+unique_key: $meta->unique_key
+unsigned: $meta->unsigned
+zerofill: $meta->zerofill
 &lt;/PRE>";
     $i++;
 }
@@ -748,7 +845,7 @@
       <paramdef>int <parameter>result</parameter></paramdef>
       <paramdef>int
        <parameter>
- <optional>result_typ</optional>
+ <optional>result_type</optional>
        </parameter>
       </paramdef>
      </funcprototype>
@@ -765,7 +862,7 @@
      their offsets (numbers are illegal property names).
     </para>
     <para>
- The optional argument <parameter>result_typ</parameter> is a
+ The optional argument <parameter>result_type</parameter> is a
      constant and can take the following values: MYSQL_ASSOC,
      MYSQL_NUM, and MYSQL_BOTH.
     </para>
@@ -775,7 +872,7 @@
      <function>mysql_fetch_row</function> (the difference is
      insignificant).
      <example>
- <title>mysql fetch object</title>
+ <title><function>mysql_fetch_object</function> example</title>
       <programlisting role="php">
 &lt;?php
 mysql_connect ($host, $user, $password);
@@ -834,6 +931,40 @@
    </refsect1>
   </refentry>
 
+ <refentry id="function.mysql-field-flags">
+ <refnamediv>
+ <refname>mysql_field_flags</refname>
+ <refpurpose>
+ Get the flags associated with the specified field in a result
+ </refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>string <function>mysql_field_flags</function></funcdef>
+ <paramdef>int <parameter>result</parameter></paramdef>
+ <paramdef>int <parameter>field_offset</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>mysql_field_flags</function> returns the field flags of
+ the specified field. The flags are reported as a single word
+ per flag separated by a single space, so that you can split the
+ returned value using <function>explode</function>.
+ </para>
+ <para>The following flags are reported, if your version of MySQL
+ is current enough to support them: "not_null", "primary_key",
+ "unique_key", "multiple_key", "blob", "unsigned", "zerofill",
+ "binary", "enum", "auto_increment", "timestamp".
+ </para>
+ <para>
+ For downward compatibility <function>mysql_fieldflags</function>
+ can also be used.
+ </para>
+ </refsect1>
+ </refentry>
+
   <refentry id="function.mysql-field-name">
    <refnamediv>
     <refname>mysql_field_name</refname>
@@ -852,13 +983,43 @@
     </funcsynopsis>
     <para>
      <function>mysql_field_name</function> returns the name of the
- specified field. Arguments to the function is the result
- identifier and the field index, ie.
- <literal>mysql_field_name($result,2);</literal>
+ specified field index. <parameter>result</parameter> must be a
+ valid result identifier and <parameter>field_index</parameter> is
+ the numerical offset of the field.
+ </para>
+ <note>
+ <para>
+ <parameter>field_index</parameter> starts at 0.
+ </para>
+ <para>
+ e.g. The index of the third field would actually be 2, the index
+ of the fourth field would be 3 and so on.
+ </para>
+ </note>
+ <para>
+ <example>
+ <title><function>mysql_field_name</function> example</title>
+ <programlisting role="php">
+// The users table consists of three fields:
+// user_id
+// username
+// password.
+
+$res = mysql_db_query("users", "select * from users", $link);
+
+echo mysql_field_name($res, 0) . "\n";
+echo mysql_field_name($res, 2);
+ </programlisting>
+ </example>
     </para>
     <para>
- Will return the name of the second field in the result associated
- with the result identifier.
+ The above example would produce the following output:
+ <informalexample>
+ <programlisting>
+user_id
+password
+ </programlisting>
+ </informalexample>
     </para>
     <para>
      For downwards compatibility <function>mysql_fieldname</function>
@@ -867,6 +1028,33 @@
    </refsect1>
   </refentry>
 
+ <refentry id="function.mysql-field-len">
+ <refnamediv>
+ <refname>mysql_field_len</refname>
+ <refpurpose>
+ Returns the length of the specified field
+ </refpurpose>
+ </refnamediv>
+ <refsect1>
+ <title>Description</title>
+ <funcsynopsis>
+ <funcprototype>
+ <funcdef>int <function>mysql_field_len</function></funcdef>
+ <paramdef>int <parameter>result</parameter></paramdef>
+ <paramdef>int <parameter>field_offset</parameter></paramdef>
+ </funcprototype>
+ </funcsynopsis>
+ <para>
+ <function>mysql_field_len</function> returns the length of the
+ specified field.
+ </para>
+ <para>
+ For downward compatibility <function>mysql_fieldlen</function>
+ can also be used.
+ </para>
+ </refsect1>
+ </refentry>
+
   <refentry id="function.mysql-field-seek">
    <refnamediv>
     <refname>mysql_field_seek</refname>
@@ -885,8 +1073,9 @@
     </funcsynopsis>
     <para>
      Seeks to the specified field offset. If the next call to
- <function>mysql_fetch_field</function> won't include a field
- offset, this field would be returned.
+ <function>mysql_fetch_field</function> doesn't include a field
+ offset, the field offset specified in
+ <function>mysql_field_seek</function> will be returned.
     </para>
     <para>
      See also: <function>mysql_fetch_field</function>.
@@ -911,8 +1100,12 @@
      </funcprototype>
     </funcsynopsis>
     <para>
- Get the table name for field. For downward compatibility
- <function>mysql_fieldtable</function> can also be used.
+ Returns the name of the table that the specifed field is
+ in.
+ </para>
+ <para>
+ For downward compatibility <function>mysql_fieldtable</function>
+ can also be used.
     </para>
    </refsect1>
   </refentry>
@@ -936,13 +1129,15 @@
     <para>
      <function>mysql_field_type</function> is similar to the
      <function>mysql_field_name</function> function. The arguments are
- identical, but the field type is returned. This will be one of
- "int", "real", "string", "blob", or others as detailed in the
- MySQL documentation.
+ identical, but the field type is returned instead. The field type
+ will be one of "int", "real", "string", "blob", and others as
+ detailed in the <ulink url="&url.mysql.docs;">MySQL
+ documentation</ulink>.
      <example>
       <title>mysql field types</title>
       <programlisting role="php">
 &lt;?php
+
 mysql_connect ("localhost:3306");
 mysql_select_db ("wisconsin");
 $result = mysql_query ("SELECT * FROM onek");
@@ -961,6 +1156,7 @@
     $i++;
 }
 mysql_close();
+
 ?>
       </programlisting>
      </example>
@@ -972,102 +1168,103 @@
    </refsect1>
   </refentry>
 
- <refentry id="function.mysql-field-flags">
+ <refentry id="function.mysql-free-result">
    <refnamediv>
- <refname>mysql_field_flags</refname>
- <refpurpose>
- Get the flags associated with the specified field in a result
- </refpurpose>
+ <refname>mysql_free_result</refname>
+ <refpurpose>Free result memory</refpurpose>
    </refnamediv>
    <refsect1>
     <title>Description</title>
     <funcsynopsis>
      <funcprototype>
- <funcdef>string <function>mysql_field_flags</function></funcdef>
+ <funcdef>int <function>mysql_free_result</function></funcdef>
       <paramdef>int <parameter>result</parameter></paramdef>
- <paramdef>int <parameter>field_offset</parameter></paramdef>
      </funcprototype>
     </funcsynopsis>
- <para>
- <function>mysql_field_flags</function> returns the field flags of
- the specified field. The flags are reported as a single word
- per flag separated by a single space, so that you can split the
- returned value using <function>explode</function>.
+ <para>
+ <function>mysql_free_result</function> will free all memory
+ associated with the result identifier <parameter>result</parameter>.
     </para>
- <para>The following flags are reported, if your version of MySQL
- is current enough to support them: "not_null", "primary_key",
- "unique_key", "multiple_key", "blob", "unsigned", "zerofill",
- "binary", "enum", "auto_increment", "timestamp".
+ <para>
+ <function>mysql_free_result</function> only needs to be called if
+ you are concerned about how much memory is being used for queries
+ that return large result sets. All associated result memory is
+ automatically freed at the end of the script's execution.
     </para>
- <para>
- For downward compatibility <function>mysql_fieldflags</function>
+ <para>
+ For downward compatibility <function>mysql_freeresult</function>
      can also be used.
     </para>
    </refsect1>
   </refentry>
 
- <refentry id="function.mysql-field-len">
+ <refentry id="function.mysql-insert-id">
    <refnamediv>
- <refname>mysql_field_len</refname>
+ <refname>mysql_insert_id</refname>
     <refpurpose>
- Returns the length of the specified field
+ Get the id generated from the previous INSERT operation
     </refpurpose>
    </refnamediv>
    <refsect1>
     <title>Description</title>
     <funcsynopsis>
      <funcprototype>
- <funcdef>int <function>mysql_field_len</function></funcdef>
- <paramdef>int <parameter>result</parameter></paramdef>
- <paramdef>int <parameter>field_offset</parameter></paramdef>
- </funcprototype>
- </funcsynopsis>
- <para>
- <function>mysql_field_len</function> returns the length of the
- specified field. For downward compatibility
- <function>mysql_fieldlen</function> can also be used.
- </para>
- </refsect1>
- </refentry>
-
- <refentry id="function.mysql-free-result">
- <refnamediv>
- <refname>mysql_free_result</refname>
- <refpurpose>Free result memory</refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>mysql_free_result</function></funcdef>
- <paramdef>int <parameter>result</parameter></paramdef>
+ <funcdef>int <function>mysql_insert_id</function></funcdef>
+ <paramdef>int
+ <parameter>
+ <optional>link_identifier</optional>
+ </parameter>
+ </paramdef>
      </funcprototype>
     </funcsynopsis>
     <para>
- <function>mysql_free_result</function> only needs to be called if
- you are worried about using too much memory while your script is
- running. All associated result memory for the specified result
- identifier will automatically be freed.
+ <function>mysql_insert_id</function> returns the ID generated for
+ an AUTO_INCREMENT column by the previous INSERT query using the
+ given <parameter>link_identifier</parameter>. If
+ <parameter>link_identifier</parameter> isn't specified, the last
+ opened link is assumed.
     </para>
     <para>
- For downward compatibility <function>mysql_freeresult</function>
- can also be used.
- </para>
+ <function>mysql_insert_id</function> returns 0 if the previous
+ query does not generate an AUTO_INCREMENT value. If you need to
+ save the value for later, be sure to call mysql_insert_id()
+ immediately after the query that generates the value.
+ </para>
+ <note>
+ <para>
+ The value of the MySQL SQL function
+ <literal>LAST_INSERT_ID()</literal> always contains the most
+ recently generated AUTO_INCREMENT value, and is not reset
+ between queries.
+ </para>
+ </note>
+ <warning>
+ <para>
+ <function>mysql_insert_id</function> converts the return type of
+ the native MySQL C API function
+ <literal>mysql_insert_id()</literal> to a type of
+ <literal>long</literal>. If your AUTO_INCREMENT column has
+ a column type of BIGINT, the value returned by
+ <function>mysql_insert_id</function> will be incorrect.
+ Instead, use the internal MySQL SQL function
+ <literal>LAST_INSERT_ID()</literal>.
+ </para>
+ </warning>
    </refsect1>
   </refentry>
 
- <refentry id="function.mysql-insert-id">
+ <refentry id="function.mysql-list-dbs">
    <refnamediv>
- <refname>mysql_insert_id</refname>
+ <refname>mysql_list_dbs</refname>
     <refpurpose>
- Get the id generated from the previous INSERT operation
+ List databases available on a MySQL server
     </refpurpose>
    </refnamediv>
    <refsect1>
     <title>Description</title>
     <funcsynopsis>
      <funcprototype>
- <funcdef>int <function>mysql_insert_id</function></funcdef>
+ <funcdef>int <function>mysql_list_dbs</function></funcdef>
       <paramdef>int
        <parameter>
         <optional>link_identifier</optional>
@@ -1075,14 +1272,46 @@
       </paramdef>
      </funcprototype>
     </funcsynopsis>
- <para>
- <function>mysql_insert_id</function> returns the ID generated for
- an AUTO_INCREMENTED field. It will return the auto-generated ID
- returned by the last INSERT query performed using the given
- <parameter>link_identifier</parameter>. If
- <parameter>link_identifier</parameter> isn't specified, the last
- opened link is assumed.
+ <para>
+ <function>mysql_list_dbs</function> will return a result pointer
+ containing the databases available from the current mysql
+ daemon. Use the <function>mysql_tablename</function> function to
+ traverse this result pointer.
+ </para>
+ <para>
+ <example>
+ <title><function>mysql_list_dbs</function> example</title>
+ <programlisting role="php">
+$link = mysql_connect('localhost', 'myname', 'secret');
+$db_list = mysql_list_dbs($link);
+
+while ($row = mysql_fetch_object($db_list)) {
+ echo $row->Database . "\n";
+}
+ </programlisting>
+ </example>
     </para>
+ <para>
+ The above example would produce the following output:
+ <informalexample>
+ <programlisting>
+database1
+database2
+database3
+...
+ </programlisting>
+ </informalexample>
+ </para>
+ <note>
+ <para>
+ The above code would just as easily work with
+ <function>mysql_fetch_row</function> or other similar functions.
+ </para>
+ </note>
+ <para>
+ For downward compatibility <function>mysql_listdbs</function> can
+ also be used.
+ </para>
    </refsect1>
   </refentry>
 
@@ -1122,40 +1351,34 @@
      will also be printed out.
     </para>
     <para>
- For downward compatibility <function>mysql_listfields</function>
- can also be used.
- </para>
- </refsect1>
- </refentry>
+ <example>
+ <title><function>mysql_list_fields</function> example</title>
+ <programlisting role="php">
+$link = mysql_connect('localhost', 'myname', 'secret');
 
- <refentry id="function.mysql-list-dbs">
- <refnamediv>
- <refname>mysql_list_dbs</refname>
- <refpurpose>
- List databases available on on MySQL server
- </refpurpose>
- </refnamediv>
- <refsect1>
- <title>Description</title>
- <funcsynopsis>
- <funcprototype>
- <funcdef>int <function>mysql_list_dbs</function></funcdef>
- <paramdef>int
- <parameter>
- <optional>link_identifier</optional>
- </parameter>
- </paramdef>
- </funcprototype>
- </funcsynopsis>
+$fields = mysql_list_fields("database1", "table1", $link);
+$columns = mysql_num_fields($fields);
+
+for ($i = 0; $i < $columns; $i++) {
+ echo mysql_field_name($fields, $i) . "\n";;
+}
+ </programlisting>
+ </example>
+ </para>
     <para>
- <function>mysql_list_dbs</function> will return a result pointer
- containing the databases available from the current mysql
- daemon. Use the <function>mysql_tablename</function> function to
- traverse this result pointer.
+ The above example would produce the following output:
+ <informalexample>
+ <programlisting>
+field1
+field2
+field3
+...
+ </programlisting>
+ </informalexample>
     </para>
     <para>
- For downward compatibility <function>mysql_listdbs</function> can
- also be used.
+ For downward compatibility <function>mysql_listfields</function>
+ can also be used.
     </para>
    </refsect1>
   </refentry>
@@ -1287,11 +1510,13 @@
      or false on error.
     </para>
     <para>
- <function>mysql_pconnect</function> establishes a connection to a
- MySQL server. All of the arguments are optional, and if they're
- missing, defaults are assumed ('localhost', user name of the user
- that owns the server process, empty password).
- </para>
+ <function>mysql_pconnect</function> establishes a connection
+ to a MySQL server. The following defaults are assumed for
+ missing optional parameters: <parameter>host:port</parameter> =
+ 'localhost:3306', <parameter>username</parameter> = name of the
+ user that owns the server process and
+ <parameter>password</parameter> = empty password.
+ </para>
     <para>
      The hostname string can also include a port
      number. eg. &quot;hostname:port&quot; or a path to a socket
@@ -1331,7 +1556,7 @@
   <refentry id="function.mysql-query">
    <refnamediv>
     <refname>mysql_query</refname>
- <refpurpose>Send an SQL query to MySQL</refpurpose>
+ <refpurpose>Send a MySQL query</refpurpose>
    </refnamediv>
    <refsect1>
     <title>Description</title>
@@ -1352,10 +1577,12 @@
      opened link is assumed. If no link is open, the function tries
      to establish a link as if <function>mysql_connect</function> was
      called with no arguments, and use it.
- </para>
- <para>
- The query string should not end with a semicolon.
     </para>
+ <note>
+ <para>
+ The query string should not end with a semicolon.
+ </para>
+ </note>
     <para>
      <function>mysql_query</function> returns TRUE (non-zero) or FALSE
      to indicate whether or not the query succeeded. A return value
@@ -1399,14 +1626,20 @@
     </para>
     <para>
      Assuming the query succeeds, you can call
+ <function>mysql_num_rows</function> to find out how many rows
+ were returned for a SELECT statment or
      <function>mysql_affected_rows</function> to find out how many
- rows were affected (for DELETE, INSERT, REPLACE, or UPDATE
- statements). For SELECT statements,
- <function>mysql_query</function> returns a new result identifier
- that you can pass to <function>mysql_result</function>. When you
- are done with the result set, you can free the resources
- associated with it by calling
- <function>mysql_free_result</function>.
+ rows were affected by a DELETE, INSERT, REPLACE, or UPDATE
+ statement.
+ </para>
+ <para>
+ For SELECT statements, <function>mysql_query</function> returns a
+ new result identifier that you can pass to
+ <function>mysql_result</function>. When you are done with the
+ result set, you can free the resources associated with it by
+ calling <function>mysql_free_result</function>. Although, the
+ memory will automatically be freed at the end of the script's
+ execution.
     </para>
     <para>
      See also: <function>mysql_affected_rows</function>,
@@ -1428,7 +1661,7 @@
     <title>Description</title>
     <funcsynopsis>
      <funcprototype>
- <funcdef>int <function>mysql_result</function></funcdef>
+ <funcdef>mixed <function>mysql_result</function></funcdef>
       <paramdef>int <parameter>result</parameter></paramdef>
       <paramdef>int <parameter>row</parameter></paramdef>
       <paramdef>mixed
@@ -1456,7 +1689,7 @@
      specifying a fieldname or tablename.fieldname argument.
     </para>
     <para>
- Calls <function>mysql_result</function> should not be mixed
+ Calls to <function>mysql_result</function> should not be mixed
      with calls to other functions that deal with the result set.
     </para>
     <para>