Table of Contents
感谢您的注册!一封确认邮件已经发送到您的邮箱。请在该电子邮件中单击链接,以激活您的帐户。
回复讨论(解决方案)
Home Backend Development PHP Tutorial 错误提示:Fatal error: Call to undefined function mysqli_num_row()

错误提示:Fatal error: Call to undefined function mysqli_num_row()

Jun 23, 2016 pm 01:59 PM

错误提示就如标题所示,网上也找了一圈,差不多都是说没有开启php_mysqli模块,我的wampserver环境本身已经开启,但是我还是去重新关闭在开启,结果都是一样,有一点很奇怪,网上一般都是在链接数据库的时候失败,但是我链接数据库没有提示失败,而是在使用mysqli_num_row时候出现错误

下面先上下我在查看phpinfo下mysqli下的开启情况
               mysqli
MysqlI Support enabled
Client API library version  mysqlnd 5.0.8-dev - 20102224 - $Id: 65fe78e70ce53d27a6cd578597722950e490b0d0 $
Active Persistent Links  0
Inactive Persistent Links  0
Active Links  0

Directive Local Value Master Value
mysqli.allow_local_infile On On
mysqli.allow_persistent On On
mysqli.default_host no value no value
mysqli.default_port 3306 3306
mysqli.default_pw no value no value
mysqli.default_socket no value no value
mysqli.default_user no value no value
mysqli.max_links Unlimited Unlimited
mysqli.max_persistent Unlimited Unlimited
mysqli.reconnect Off Off


下面是我的代码部分

<?phprequire ('inc/config.php');$page_title = '注册-CNode博客';include ('inc/header.php');if ($_SERVER['REQUEST_METHOD'] == 'POST') {	require (MYSQL);	$trimmed = array_map('trim', $_POST);	$errors = array();	if ($_POST['code'] != $_SESSION['code']) {		$errors[] = '验证码不正确!';	}	if(empty($trimmed['username'])) {		$errors[] = '用户名不能为空';	} else {		if (preg_match ('/^[A-Z \'.-]{5,20}$/i', $trimmed['username'])) {			$un = mysqli_real_escape_string ($conn, $trimmed['username']);		} else {			$errors[] = '您的用户名格式不对';		}	}		if(empty($trimmed['email'])) {		$errors[] = '电子邮件地址不能为空';	} else {		if (filter_var($trimmed['email'], FILTER_VALIDATE_EMAIL)) {			$e = mysqli_real_escape_string ($conn, $trimmed['email']);		} else {			$errors[] = '您的电子邮件地址格式不对';		}	}		if(!empty($trimmed['password'])) {				if (preg_match ('/^\w{4,20}$/', $trimmed['password']) ) {			if ($trimmed['password'] == $trimmed['notpassword']) {				$p = mysqli_real_escape_string ($conn, $trimmed['password']);			} else {				$errors[] = '登录密码和确认密码不一致';			}		} else {			$errors[] = '请输入有效的登录密码';		}			} else {		$errors[] = '登录密码不能为空';	}		if(empty($trimmed['notpassword'])) {		$errors[] = '确认密码不能为空';	}		if (empty($errors)) {		// 确定电子邮件是否被使用		$q = "SELECT user_id FROM users WHERE email='$e'";		$r = mysqli_query ($conn, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($conn));		if (mysqli_num_row($r) == 0) { // 如果查询验证电子邮件地址未被使用,则注册用户			$a = md5(uniqid(rand(), true)); // 创建一个激活码(创建一个长度正好为32个字符的字符串)			$q = "INSERT INTO users (username, email, password, active, registration_date) VALUES ('$un', '$e', SHA1('$p'), '$a', NOW() )";			$r = mysqli_query ($conn, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($conn));				if (mysqli_affected_rows($conn) == 1) {				$body = "感谢您的注册,激活您的帐户,请点击这里:\n\n";				$body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a";				mail($trimmed['email'], '确认注册', $body, 'From: 414412984@qq.com');				echo '<h3 id="感谢您的注册-一封确认邮件已经发送到您的邮箱-请在该电子邮件中单击链接-以激活您的帐户">感谢您的注册!一封确认邮件已经发送到您的邮箱。请在该电子邮件中单击链接,以激活您的帐户。</h3>';				exit();		 	} else { 				echo '<p class="error">用户注册失败,为此我们表示抱歉,请在注册一次</p>';			}				} else { // 查询验证出来的电子邮件地址已经被注册			echo '<p class="error">电子邮件地址已经被注册</p>';		}	} else {		foreach ($errors as $msg) { // Print each error.			echo " - $msg<br />\n";		}	}	mysqli_close($conn);}?><div class="wrap login">	<div class="path"><a href="#">主页</a> > 注册</div>	<div class="info">    <form method="post" name="register" action="">		<p>		  <label for="username">用户名:</label><input type="text" name="username" id="username" class="text" value="<?php if (isset($trimmed['username'])) echo $trimmed['username']; ?>" />		  <span>限5~20个字符,可用中文、英文、数字及“_”、“-”组成</span>		</p>        <p>          <label for="email">电子邮件:</label><input type="text" name="email" id="email" class="text" value="<?php if (isset($trimmed['email'])) echo $trimmed['email']; ?>" />          <span>请填写您的常用邮箱,它是您激活帐号和找回密码的凭证!</span>        </p>        		<p>		  <label for="password">登录密码:</label><input type="password" name="password" id="password" class="text" value="<?php if (isset($trimmed['password'])) echo $trimmed['password']; ?>" />		  <span>密码由4-20位字母、数字组成</span>		</p>		<p>          <label for="notpassword">确认密码:</label><input type="password" name="notpassword" id="notpassword" class="text" value="<?php if (isset($trimmed['notpassword'])) echo $trimmed['notpassword']; ?>" />          <span>请再次输入密码</span>        </p>				<p>		  <label for="yzm">验证码:</label><input type="text" name="code" id="yzm" class="text1" />		  <img  src="/static/imghw/default1.png"  data-src="code.php"  class="lazy"   id="code" / alt="错误提示:Fatal error: Call to undefined function mysqli_num_row()" >          <span>看不清,请重新点击验证码(注意大小写)</span>		</p>		<div class="submit">		   <input type="submit" name="submit" class="btn-1" value="立即注册" />		</div>	</form>	</div>	</div>	<?phpinclude ('inc/footer.php');?>
Copy after login


回复讨论(解决方案)

print_r(get_extension_funcs('mysqli'));
Copy after login

你自己看看有没有
Array
(
    [0] => mysqli_affected_rows
    [1] => mysqli_autocommit
    [2] => mysqli_change_user
    [3] => mysqli_character_set_name
    [4] => mysqli_close
    [5] => mysqli_commit
    [6] => mysqli_connect
    [7] => mysqli_connect_errno
    [8] => mysqli_connect_error
    [9] => mysqli_data_seek
    [10] => mysqli_dump_debug_info
    [11] => mysqli_debug
    [12] => mysqli_errno
    [13] => mysqli_error
    [14] => mysqli_error_list
    [15] => mysqli_stmt_execute
    [16] => mysqli_execute
    [17] => mysqli_fetch_field
    [18] => mysqli_fetch_fields
    [19] => mysqli_fetch_field_direct
    [20] => mysqli_fetch_lengths
    [21] => mysqli_fetch_all
    [22] => mysqli_fetch_array
    [23] => mysqli_fetch_assoc
    [24] => mysqli_fetch_object
    [25] => mysqli_fetch_row
    [26] => mysqli_field_count
    [27] => mysqli_field_seek
    [28] => mysqli_field_tell
    [29] => mysqli_free_result
    [30] => mysqli_get_connection_stats
    [31] => mysqli_get_client_stats
    [32] => mysqli_get_charset
    [33] => mysqli_get_client_info
    [34] => mysqli_get_client_version
    [35] => mysqli_get_host_info
    [36] => mysqli_get_proto_info
    [37] => mysqli_get_server_info
    [38] => mysqli_get_server_version
    [39] => mysqli_get_warnings
    [40] => mysqli_init
    [41] => mysqli_info
    [42] => mysqli_insert_id
    [43] => mysqli_kill
    [44] => mysqli_more_results
    [45] => mysqli_multi_query
    [46] => mysqli_next_result
    [47] => mysqli_num_fields
    [48] =>  mysqli_num_rows 这个是你要的吗?但你写错了
    [49] => mysqli_options
    [50] => mysqli_ping
    [51] => mysqli_poll
    [52] => mysqli_prepare
    [53] => mysqli_report
    [54] => mysqli_query
    [55] => mysqli_real_connect
    [56] => mysqli_real_escape_string
    [57] => mysqli_real_query
    [58] => mysqli_reap_async_query
    [59] => mysqli_rollback
    [60] => mysqli_select_db
    [61] => mysqli_set_charset
    [62] => mysqli_stmt_affected_rows
    [63] => mysqli_stmt_attr_get
    [64] => mysqli_stmt_attr_set
    [65] => mysqli_stmt_bind_param
    [66] => mysqli_stmt_bind_result
    [67] => mysqli_stmt_close
    [68] => mysqli_stmt_data_seek
    [69] => mysqli_stmt_errno
    [70] => mysqli_stmt_error
    [71] => mysqli_stmt_error_list
    [72] => mysqli_stmt_fetch
    [73] => mysqli_stmt_field_count
    [74] => mysqli_stmt_free_result
    [75] => mysqli_stmt_get_result
    [76] => mysqli_stmt_get_warnings
    [77] => mysqli_stmt_init
    [78] => mysqli_stmt_insert_id
    [79] => mysqli_stmt_more_results
    [80] => mysqli_stmt_next_result
    [81] => mysqli_stmt_num_rows
    [82] => mysqli_stmt_param_count
    [83] => mysqli_stmt_prepare
    [84] => mysqli_stmt_reset
    [85] => mysqli_stmt_result_metadata
    [86] => mysqli_stmt_send_long_data
    [87] => mysqli_stmt_store_result
    [88] => mysqli_stmt_sqlstate
    [89] => mysqli_sqlstate
    [90] => mysqli_ssl_set
    [91] => mysqli_stat
    [92] => mysqli_store_result
    [93] => mysqli_thread_id
    [94] => mysqli_thread_safe
    [95] => mysqli_use_result
    [96] => mysqli_warning_count
    [97] => mysqli_refresh
    [98] => mysqli_escape_string
    [99] => mysqli_set_opt
)

真是和你说的一样,太粗心了,你给的方法很直观,谢谢

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1659
14
PHP Tutorial
1257
29
C# Tutorial
1231
24
How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Explain different error types in PHP (Notice, Warning, Fatal Error, Parse Error). Explain different error types in PHP (Notice, Warning, Fatal Error, Parse Error). Apr 08, 2025 am 12:03 AM

There are four main error types in PHP: 1.Notice: the slightest, will not interrupt the program, such as accessing undefined variables; 2. Warning: serious than Notice, will not terminate the program, such as containing no files; 3. FatalError: the most serious, will terminate the program, such as calling no function; 4. ParseError: syntax error, will prevent the program from being executed, such as forgetting to add the end tag.

What are HTTP request methods (GET, POST, PUT, DELETE, etc.) and when should each be used? What are HTTP request methods (GET, POST, PUT, DELETE, etc.) and when should each be used? Apr 09, 2025 am 12:09 AM

HTTP request methods include GET, POST, PUT and DELETE, which are used to obtain, submit, update and delete resources respectively. 1. The GET method is used to obtain resources and is suitable for read operations. 2. The POST method is used to submit data and is often used to create new resources. 3. The PUT method is used to update resources and is suitable for complete updates. 4. The DELETE method is used to delete resources and is suitable for deletion operations.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

Explain Arrow Functions (short closures) introduced in PHP 7.4. Explain Arrow Functions (short closures) introduced in PHP 7.4. Apr 06, 2025 am 12:01 AM

The arrow function was introduced in PHP7.4 and is a simplified form of short closures. 1) They are defined using the => operator, omitting function and use keywords. 2) The arrow function automatically captures the current scope variable without the use keyword. 3) They are often used in callback functions and short calculations to improve code simplicity and readability.

See all articles