FANDOM


// coba koneksi ke MySQL database
$conn = mysql_connect("localhost", "username", "password");

// jika koneksi gagal, display error dan exit program
if(!$conn) { die('Could not connect: '.mysql_error()); }

// pilih database yang akan digunakan
mysql_select_db("databaseku");

// query database
$result = mysql_query("sql statement"); // cek keberhasilan query
if(!$result) die('Query gagal: '.mysql_error());

// cek berapa banyak record yang dikembalikan oleh SELECT statement
$num = mysql_num_rows($result); if($num == 0) echo 'No record';

// cek berapa banyak record yg diupdate oleh INSERT, UPDATE, REPLACE, DELETE
$num = mysql_affected_rows($result);

// get records
while ($row = mysql_fetch_assoc($result)) { echo $row["column1"]; echo $row["column2"]; }

// free result sets -- ngga perlu juga kecuali memang maunya sendiri
mysql_free_result($result);
// setelah selesai menggunakan database sebaiknya tutup koneksinya
// Note: tidak perlu karena resource akan di bebaskan secara otomatis mysql_close($conn);

mysql_affected_rowsGet number of affected rows in previous MySQL operation
mysql_client_encodingReturns the name of the character set
mysql_closeClose MySQL connection
mysql_connectOpen a connection to a MySQL Server
mysql_create_dbCreate a MySQL database
mysql_data_seekMove internal result pointer
mysql_db_nameGet result data
mysql_db_querySend a MySQL query
mysql_drop_dbDrop (delete) a MySQL database
mysql_errnoReturns the numerical value of the error message from previous MySQL operation
mysql_errorReturns the text of the error message from previous MySQL operation
mysql_escape_stringEscapes a string for use in a mysql_query
mysql_fetch_arrayFetch a result row as an associative array, a numeric array, or both
mysql_fetch_assocFetch a result row as an associative array
mysql_fetch_fieldGet column information from a result and return as an object
mysql_fetch_lengthsGet the length of each output in a result
mysql_fetch_objectFetch a result row as an object
mysql_fetch_rowGet a result row as an enumerated array
mysql_field_flagsGet the flags associated with the specified field in a result
mysql_field_lenReturns the length of the specified field
mysql_field_nameGet the name of the specified field in a result
mysql_field_seekSet result pointer to a specified field offset
mysql_field_tableGet name of the table the specified field is in
mysql_field_typeGet the type of the specified field in a result
mysql_free_resultFree result memory
mysql_get_client_infoGet MySQL client info
mysql_get_host_infoGet MySQL host info
mysql_get_proto_infoGet MySQL protocol info
mysql_get_server_infoGet MySQL server info
mysql_infoGet information about the most recent query
mysql_insert_idGet the ID generated in the last query
mysql_list_dbsList databases available on a MySQL server
mysql_list_fieldsList MySQL table fields
mysql_list_processesList MySQL processes
mysql_list_tablesList tables in a MySQL database
mysql_num_fieldsGet number of fields in result
mysql_num_rowsGet number of rows in result
mysql_pconnectOpen a persistent connection to a MySQL server
mysql_pingPing a server connection or reconnect if there is no connection
mysql_querySend a MySQL query
mysql_real_escape_stringEscapes special characters in a string for use in an SQL statement
mysql_resultGet result data
mysql_select_dbSelect a MySQL database
mysql_set_charsetSets the client character set
mysql_statGet current system status
mysql_tablenameGet table name of field
mysql_thread_idReturn the current thread ID
mysql_unbuffered_querySend an SQL query to MySQL without fetching and buffering the result rows.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.