Mysql can be connected to the web through PHP in two ways, one is Mysql-related functions through php, and the other is ODBC-related functions through php.
The related functions are as follows:
MYSQL Functions
Mysql_affected_rows: obtain the number of columns affected by the last MySQL operation.
Mysql_close: disconnect the MySQL server.
Mysql_connect: enables connections to the MySQL server.
Mysql_create_db: Create a New MySQL database.
Mysql_data_seek: Move internal return indicator.
Mysql_db_query: Send the query string to the MySQL database.
Mysql_drop_db: remove the database.
Mysql_errno: return the error code.
Mysql_error: returns an error message.
Mysql_fetch_array: returns the array data.
Mysql_fetch_field: obtains the field information.
Mysql_fetch_lengths: returns the maximum length of data in each column of a single column.
Mysql_fetch_object: returns object data.
Mysql_fetch_row: returns the columns of a single column.
Mysql_field_name: return the name of the specified field.
Mysql_field_seek: Set a field from the indicator to the returned value.
Mysql_field_table: Obtain the name of the table in the current column.
Mysql_field_type: Obtain the current column type.
Mysql_field_flags: obtains the flag of the current field.
Mysql_field_len: Get the length of the current column.
Mysql_free_result: releases the memory occupied by the returned data.
Mysql_insert_id: return the ID of the last INSERT command.
Mysql_list_fields: lists the fields of a specified data table ).
Mysql_list_dbs: List available databases of the MySQL server ).
Mysql_list_tables: lists the tables of a specified database ).
Mysql_num_fields: gets the number of returned fields.
Mysql_num_rows: gets the number of returned columns.
Mysql_pconnect: enables long-term connections to the MySQL server.
Mysql_query: returns a query string.
Mysql_result: gets the query result.
Mysql_select_db: select a database.
Mysql_tablename: Get the table name.
ODBC Functions
To Use ODBC functions, you must install MYSQL ODBC
Odbc_autocommit: Enables or disables automatic change.
Odbc_binmode: sets the binary data processing method.
Odbc_close: Close the ODBC link.
Odbc_close_all: Close all ODBC connections.
Odbc_commit: updates the ODBC database.
Odbc_connect: connect to the ODBC database.
Odbc_cursor: Get the cursor name.
Odbc_do: Execute SQL commands.
Odbc_exec: Execute SQL commands.
Odbc_execute: Execute the preset SQL command.
Odbc_fetch_into: gets the specified column returned.
Odbc_fetch_row: returns a column.
Odbc_field_name: obtains the column name.
Odbc_field_type: obtains the column data format.
Odbc_field_len: obtains the length of the column data.
Odbc_free_result: refers to the memory used to send data back.
Odbc_longreadlen: sets the maximum value of the return column.
Odbc_num_fields: obtains the number of fields.
Odbc_pconnect: long-term connection to the ODBC database.
Odbc_prepare: preset SQL commands.
Odbc_num_rows: gets the number of returned columns.
Odbc_result: Obtain the returned data.
Odbc_result_all: returns HTML table data.
Odbc_rollback: undo the current transaction.
Odbc_setoption: adjusts ODBC settings.
Example: foreground HTML
<Form enctype = "multipart/form-data" action = "hb_ggzd.php" method = "post">
<Tr>
<Td width = "251"> <small> you can enter a table in the interval or use the power
Sub-mail, <a href = "mailto: likai333@21cn.com"> likai333@21cn.com </a>. </Small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "31"> <small> your name: </small> </td>
<Td width = "462" height = "31"> <small> <input name = "name" size = "20"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "30"> <small> your email: </small> </td>
<Td width = "462" height = "30"> <small> <input name = "usermail" size = "37"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "25"> <small> the website address you want to advertise: </small> </td>
<Td width = "462" height = "25"> <small> <input name = "userurl" size = "37" value = "http: // "> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "25"> <small> website name to be advertised: </small> </td>
<Td width = "462" height = "25"> <small> <input name = "sitename" size = "20"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "30"> <small> your company name: </small> </td>
<Td width = "462" height = "30"> <small> <input name = "company" size = "37"> </small> </td>
</Tr>
<Tr>
<Td vAlign = "top" width = "251" height = "25"> <small> contact number: </small> </td>
<Td width = "462" height = "25"> <small> <input name = "phone" size = "20"> </small> </td>
</Tr>
<Tr>
Background PHP:
<? Php
= Mysql_connect (localhost: 3306, root ,);
Mysql_select_db (HBWEB );
= "Insert into usemsg (name, usermail, userurl, sitename, company, phone) values (,,,,,,,,,,)";
= Mysql_query (,);
= Mysql_error ();
If (){
Echo "An error occurred, please notify <a href = mailto: likai333@21cn.com> mE </a> ";
Echo "";
}
Else
{Echo "successful warehouse receiving ";}
? >
Table Structure:
Create table usemsg (
Name varchar (255) not null default "notname ",
Usermail varchar (255) not null default "notusermail ",
User URL varchar (255) not null default "notuserurl ",
Sitename varchar (255) not null default "notsitename ",
Company varchar (255) not null default "notcompany ",
Phone varchar (255) not null default "notphone ",
);