Mysql_affected_rows () and mysql_num_rows () Differences in PHP

Source: Internet
Author: User

Mysql_affected_rows--The number of record rows affected by the previous MySQL operation
Mysql_num_rows--function returns the number of rows in the result set.

config.php

1<?PHP2     Header(' content-type:text/html; Charset=utf-8 ');3     4     Define(' db_host ', ' localhost ');5     Define(' Db_user ', ' root ');6     Define(' Db_pwd ', ' 123456 ');7     Define(' db_name ', ' Zhiwen ');8     9     $conn= @mysql_connect(Db_host, Db_user, db_pwd) or die(' Database link failed: '.Mysql_error());Ten      One@mysql_select_db(db_name) or die(' Database error: '.Mysql_error()); A      -@mysql_query(' SET NAMES UTF8 ') or die(' Character set error: '.Mysql_error()); -?>
<? PHP
1<?PHP2     Sleep(3);3     require' Config.php ';4     5     $query= "INSERT into user (user, pass, email, sex, birthday, date)6VALUES (' {$_post[' User ']} ', SHA1 (' {$_post[' Pass ']} '), ' {$_post[' Email ']} ', ' {$_post[' Sex ']} ', ' {$_post[' Birthday ']} ', now ()) ";7     8     mysql_query($query) or die(' New failed! ‘.Mysql_error());9     Ten     Echo mysql_affected_rows(); One      A     Mysql_close(); -?>
$conn=mysql_connect(' localhost ', ' root ', '); // connecting to a database mysql_select_db (' flag '); // Select Database Echo mysql_affected_rows  ?>// the number of record rows affected by the Insert,update or DELETE query. 
<? PHP mysql_connect (' localhost ', ' root ', '); // connecting to a database mysql_select_db (' flag '); // Select Database $query=mysql_query(' SELECT * from Test '); // Execute Query Distance Echo mysql_num_rows ($query);? >// result is the number of rows returned for the query

Can be understood as mysql_affected_rows (); The number of record rows that are commonly affected by insert,update or delete, and mysql_num_rows (); Is the number of rows that return a select query

75 basic MySQL C APIs

Mysql_affected_rows ();
Mysql_autocommit ();
Mysql_change_user ();
Mysql_character_set_name ();
Mysql_close ();
Mysql_commit ();
Mysql_connect ();
mysql_create_db ();
Mysql_data_seek ();
Mysql_debug ();
mysql_drop_db ();
Mysql_dump_debug_info ();
Mysql_eof ();
Mysql_errno ();
Mysql_error ();
Mysql_escape_string ();
Mysql_fetch_field ();
Mysql_fetch_field_direct ();
Mysql_fetch_fields ();
Mysql_fetch_lengths ();
Mysql_fetch_row ();
Mysql_field_count ();
Mysql_field_seek ();
Mysql_field_tell ();
Mysql_free_result ();
Mysql_get_client_info ();
Mysql_get_character_set_info ();
Mysql_get_client_version ();
Mysql_get_host_info ();
Mysql_get_proto_info ();
Mysql_get_server_info ();
Mysql_get_server_version ();
Mysql_get_ssl_cipher ();
Mysql_hex_string ();
Mysql_info ();
Mysql_init ();
MYSQL_INSERT_ID ();
Mysql_kill ();
Mysql_library_end ();
Mysql_library_init ();
Mysql_list_dbs ();
Mysql_list_fields ();
Mysql_list_processes ();
Mysql_list_tables ();
Mysql_more_results ();
Mysql_next_result ();
Mysql_num_fields ();
Mysql_num_rows ();
Mysql_options ();
Mysql_ping ();
Mysql_query ();
Mysql_real_connect ();
Mysql_real_escape_string ();
Mysql_real_query ();
Mysql_reload ();
Mysql_refresh ();
Mysql_rollback ();
Mysql_row_seek ();
Mysql_row_tell ();
mysql_select_db ();
Mysql_set_character_set ();
Mysql_set_local_infile_default ();
Mysql_set_local_infile_handler ();
Mysql_set_server_option ();
Mysql_shutdown ();
Mysql_sqlstate ();
Mysql_ssl_set ();
Mysql_stat ();
Mysql_store_result ();
Mysql_thread_end ();
MYSQL_THREAD_ID ();
Mysql_thread_init ();
Mysql_thread_safe ();
Mysql_use_result ();
Mysql_warning_count ();

Mysql_affected_rows () and mysql_num_rows () Differences in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.