错误提示:Fatal error: Call to undefined function mysqli_num_row()
错误提示就如标题所示,网上也找了一圈,差不多都是说没有开启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
下面是我的代码部分
<?php <br />require ('inc/config.php');<br>$page_title = '注册-CNode博客';<br>include ('inc/header.php');<br>if ($_SERVER['REQUEST_METHOD'] == 'POST') {<br> require (MYSQL);<br> $trimmed = array_map('trim', $_POST);<br> $errors = array();<br> if ($_POST['code'] != $_SESSION['code']) {<br> $errors[] = '验证码不正确!';<br> }<br> if(empty($trimmed['username'])) {<br> $errors[] = '用户名不能为空';<br> } else {<br> if (preg_match ('/^[A-Z \'.-]{5,20}$/i', $trimmed['username'])) {<br> $un = mysqli_real_escape_string ($conn, $trimmed['username']);<br> } else {<br> $errors[] = '您的用户名格式不对';<br> }<br> }<br> <br> if(empty($trimmed['email'])) {<br> $errors[] = '电子邮件地址不能为空';<br> } else {<br> if (filter_var($trimmed['email'], FILTER_VALIDATE_EMAIL)) {<br> $e = mysqli_real_escape_string ($conn, $trimmed['email']);<br> } else {<br> $errors[] = '您的电子邮件地址格式不对';<br> }<br> }<br> <br> if(!empty($trimmed['password'])) { <br> if (preg_match ('/^\w{4,20}$/', $trimmed['password']) ) {<br> if ($trimmed['password'] == $trimmed['notpassword']) {<br> $p = mysqli_real_escape_string ($conn, $trimmed['password']);<br> } else {<br> $errors[] = '登录密码和确认密码不一致';<br> }<br> } else {<br> $errors[] = '请输入有效的登录密码';<br> } <br> } else {<br> $errors[] = '登录密码不能为空';<br> } <br> if(empty($trimmed['notpassword'])) {<br> $errors[] = '确认密码不能为空';<br> }<br> <br> if (empty($errors)) {<br> // 确定电子邮件是否被使用<br> $q = "SELECT user_id FROM users WHERE email='$e'";<br> $r = mysqli_query ($conn, $q) or trigger_error("Query: $q\n<br>MySQL Error: " . mysqli_error($conn));<br> if (mysqli_num_row($r) == 0) { // 如果查询验证电子邮件地址未被使用,则注册用户<br> $a = md5(uniqid(rand(), true)); // 创建一个激活码(创建一个长度正好为32个字符的字符串)<br> $q = "INSERT INTO users (username, email, password, active, registration_date) VALUES ('$un', '$e', SHA1('$p'), '$a', NOW() )";<br> $r = mysqli_query ($conn, $q) or trigger_error("Query: $q\n<br>MySQL Error: " . mysqli_error($conn)); <br> if (mysqli_affected_rows($conn) == 1) {<br> $body = "感谢您的注册,激活您的帐户,请点击这里:\n\n";<br> $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a";<br> mail($trimmed['email'], '确认注册', $body, 'From: [email protected]');<br> echo '<h3 id="感谢您的注册-一封确认邮件已经发送到您的邮箱-请在该电子邮件中单击链接-以激活您的帐户">感谢您的注册!一封确认邮件已经发送到您的邮箱。请在该电子邮件中单击链接,以激活您的帐户。</h3>';<br> exit();<br> } else { <br> echo '<p>用户注册失败,为此我们表示抱歉,请在注册一次</p>';<br> } <br> } else { // 查询验证出来的电子邮件地址已经被注册<br> echo '<p>电子邮件地址已经被注册</p>';<br> }<br> } else {<br> foreach ($errors as $msg) { // Print each error.<br> echo " - $msg<br>\n";<br> }<br> }<br> mysqli_close($conn);<br>}<br>?><br><br><div> <br> <div> <a>主页</a> > 注册</div> <br> <div> <br> <form> <br> <p><br> <label>用户名:</label><input>" /><br> <span>限5~20个字符,可用中文、英文、数字及“_”、“-”组成</span><br> </p> <br> <p><br> <label>电子邮件:</label><input>" /><br> <span>请填写您的常用邮箱,它是您激活帐号和找回密码的凭证!</span></p> <div class="clear"> </div> </form> </div> </div>

TooptimizePHPcodeforreducedmemoryusageandexecutiontime,followthesesteps:1)Usereferencesinsteadofcopyinglargedatastructurestoreducememoryconsumption.2)LeveragePHP'sbuilt-infunctionslikearray_mapforfasterexecution.3)Implementcachingmechanisms,suchasAPC

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
