mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Some examples corrected.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@26387 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
ff6b25913d
commit
a9fe103886
1 changed files with 18 additions and 24 deletions
|
@ -120,9 +120,8 @@
|
|||
<title>MySQL close example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$link = mysql_connect ("kraemer", "marliesle", "secret") {
|
||||
$link = mysql_connect ("kraemer", "marliesle", "secret")
|
||||
or die ("Could not connect");
|
||||
}
|
||||
print ("Connected successfully");
|
||||
mysql_close ($link);
|
||||
?>
|
||||
|
@ -206,9 +205,8 @@
|
|||
<title>MySQL connect example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$link = mysql_connect ("kraemer", "marliesle", "secret") {
|
||||
$link = mysql_connect ("kraemer", "marliesle", "secret")
|
||||
or die ("Could not connect");
|
||||
}
|
||||
print ("Connected successfully");
|
||||
mysql_close ($link);
|
||||
?>
|
||||
|
@ -246,9 +244,8 @@
|
|||
<title>MySQL create database example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$link = mysql_pconnect ("kron", "jutta", "geheim") {
|
||||
$link = mysql_pconnect ("kron", "jutta", "geheim")
|
||||
or die ("Could not connect");
|
||||
}
|
||||
if (mysql_create_db ("my_db")) {
|
||||
print ("Database created successfully\n");
|
||||
} else {
|
||||
|
@ -258,8 +255,8 @@
|
|||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
For downwards compatibility <function>mysql_createdb</function> can also be
|
||||
used.
|
||||
For downwards compatibility <function>mysql_createdb</function>
|
||||
can also be used.
|
||||
</para>
|
||||
<para>
|
||||
See also: <function>mysql_drop_db</function>.
|
||||
|
@ -296,18 +293,15 @@
|
|||
<title>MySQL data seek example</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
$link = mysql_pconnect ("kron", "jutta", "geheim") {
|
||||
$link = mysql_pconnect ("kron", "jutta", "geheim")
|
||||
or die ("Could not connect");
|
||||
}
|
||||
|
||||
mysql_select_db ("samp_db") {
|
||||
mysql_select_db ("samp_db")
|
||||
or die ("Could not select database");
|
||||
}
|
||||
|
||||
$query = "SELECT last_name, first_name FROM friends";
|
||||
$result = mysql_query ($query) {
|
||||
$result = mysql_query ($query)
|
||||
or die ("Query failed");
|
||||
}
|
||||
|
||||
# fetch rows in reverse order
|
||||
|
||||
|
@ -756,13 +750,13 @@ mysql_free_result ($result);
|
|||
<title>mysql fetch object</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
mysql_connect($host,$user,$password);
|
||||
$result = mysql_db_query("database","select * from table");
|
||||
while($row = mysql_fetch_object($result)) {
|
||||
mysql_connect ($host, $user, $password);
|
||||
$result = mysql_db_query ("database", "select * from table");
|
||||
while ($row = mysql_fetch_object ($result)) {
|
||||
echo $row->user_id;
|
||||
echo $row->fullname;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
mysql_free_result ($result);
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -911,13 +905,13 @@ mysql_free_result($result);
|
|||
<title>mysql field types</title>
|
||||
<programlisting role="php">
|
||||
<?php
|
||||
mysql_connect("localhost:3306");
|
||||
mysql_select_db("wisconsin");
|
||||
$result = mysql_query("SELECT * FROM onek");
|
||||
$fields = mysql_num_fields($result);
|
||||
$rows = mysql_num_rows($result);
|
||||
mysql_connect ("localhost:3306");
|
||||
mysql_select_db ("wisconsin");
|
||||
$result = mysql_query ("SELECT * FROM onek");
|
||||
$fields = mysql_num_fields ($result);
|
||||
$rows = mysql_num_rows ($result);
|
||||
$i = 0;
|
||||
$table = mysql_field_table($result, $i);
|
||||
$table = mysql_field_table ($result, $i);
|
||||
echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <BR>";
|
||||
echo "The table has the following fields <BR>";
|
||||
while ($i < $fields) {
|
||||
|
|
Loading…
Reference in a new issue