betz Mon Oct 3 06:37:10 2005 EDT
Modified files:
/phpdoc/en/reference/mysql/functions mysql-connect.xml
Log:
more examples for connecting with different syntax, link to client flags
table, link to ini-setting
http://cvs.php.net/diff.php/phpdoc/en/reference/mysql/functions/mysql-connect.xml?r1=1.16&r2=1.17&ty=u
Index: phpdoc/en/reference/mysql/functions/mysql-connect.xml
diff -u phpdoc/en/reference/mysql/functions/mysql-connect.xml:1.16
phpdoc/en/reference/mysql/functions/mysql-connect.xml:1.17
--- phpdoc/en/reference/mysql/functions/mysql-connect.xml:1.16 Mon Jun 20
23:05:09 2005
+++ phpdoc/en/reference/mysql/functions/mysql-connect.xml Mon Oct 3
06:37:09 2005
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.16 $ -->
+<!-- $Revision: 1.17 $ -->
<refentry id="function.mysql-connect">
<refnamediv>
<refname>mysql_connect</refname>
@@ -80,6 +80,7 @@
<constant>MYSQL_CLIENT_COMPRESS</constant>,
<constant>MYSQL_CLIENT_IGNORE_SPACE</constant> or
<constant>MYSQL_CLIENT_INTERACTIVE</constant>.
+ Read the section about <xref linkend="mysql.client-flags" /> for
further information.
</para>
</listitem>
</varlistentry>
@@ -156,6 +157,61 @@
</programlisting>
</example>
</para>
+ <para>
+ <example>
+ <title><function>mysql_connect</function>example using
<literal>hostname:port</literal> syntax</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// we connect to example.com and port 3307
+$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+
+// we connect to localhost at port 3307
+$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ <para>
+ <example>
+ <title><function>mysql_connect</function>example using ":/path/to/socket"
syntax</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+// we connect to localhost and socket e.g. /tmp/mysql.sock
+
+//variant 1: ommit localhost
+$link = mysql_connect('/tmp/mysql', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+
+
+// variant 2: with localhost
+$link = mysql_connect('localhost:/tmp/mysql.sock', 'mysql_user',
'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
</refsect1>
<refsect1 role="notes">
@@ -168,7 +224,7 @@
Windows). If you want to use TCP/IP, use "127.0.0.1"
instead of "localhost". If the MySQL client library tries to
connect to the wrong local socket, you should set the correct path as
- mysql.default_host in your PHP configuration and leave the server field
+ <xref linkend=" ini.mysql.default-host" /> in your PHP configuration and
leave the server field
blank.
</para>
</note>