Professional Documents
Culture Documents
$dbhost = localhost;
$dbuser = guest;
$dbpass = ;
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
a)mysql_conncetion(localhost,root,);
5)select database::my_select_db(admin);
11) mysql_fetch_array() can be used to fetch all the selected data. This function returns row as an associative array, a numeric
array, or both. This function returns FALSE if there are no more rows.
12) Always remember to put curly brackets when you want to insert an array value directly into a string.
In above example, the constant MYSQL_ASSOC is used as the second argument to PHP function
mysql_fetch_array(), so that it returns the row as an associative array. With an associative array, you can access
the field by using their name instead of using the index.
13)PHP provides another function called mysql_fetch_assoc(), which also returns the row as an associative array.
while($row = mysql_fetch_assoc($retval))
{
echo "Tutorial ID :{$row['tutorial_id']} <br> ".
"Title: {$row['tutorial_title']} <br> ".
"Author: {$row['tutorial_author']} <br> ".
"Submission Date : {$row['submission_date']} <br> ".
"--------------------------------<br>";
}
14)mysql_num:: You can also use the constant MYSQL_NUM as the second argument to PHP function
mysql_fetch_array(). This will cause the function to return an array with numeric index.
Example:
Try out the following e
mysql_select_db('mydb');
16)update record
/* Update records */
mysql_query("UPDATE mytable SET used=1 WHERE id < 10");
printf ("Updated records: %d\n", mysql_affected_rows());
mysql_query("COMMIT");
Note: Transactions
If you are using transactions, you need to call mysql_affected_rows() after your
INSERT, UPDATE, or DELETE query, not after the COMMIT.
Note: SELECT Statements
To retrieve the number of rows returned by a SELECT, it is possible to
use mysql_num_rows().
Note: Cascaded Foreign Keys
mysql_affected_rows() does not count rows affected implicitly through the use of ON
DELETE CASCADE and/or ON UPDATE CASCADE in foreign key constraints.
20) mysql_close::
22) mysql_create_db() attempts to create a new database on the server associated with
the specified link identifier.
24) mysql_db_name
(PHP 4, PHP 5)
25) Returns the database name on success, and FALSE on failure. If FALSE is returned,
use mysql_error() to determine the nature of the error.
26) Note:
For backward compatibility, the following deprecated alias may be
used: mysql_dbname()
mysql_errno Returns the numerical value of the error message from previous MySQL
operation
32) mysql_error
mysql_error Returns the text of the error message from previous MySQL operation
33) mysql_escape_string
34)