本文介绍了致命错误:未捕获错误:调用C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\第2行的\project\r.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 警告:mysqli :: __ construct()期望参数5为整数,第35行的C:\ xampp \\\ htdocs \ project @\\ contatedemo.php中给出的字符串 警告:mysqli :: query():无法在第44行的C:\ xampp \ htdocs \ project #\\contactdemo.php中获取mysqli 警告:main():无法在第50行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ (用户名,电子邮件,手机,主题)值('Rahul','ragavi @ gmail.com','8105189061','nvjmlik') 警告:mysqli :: close():无法在第52行的C:\ xampp \ htdocs \ project #\\contactdemo.php中获取mysqli 我尝试了什么: <?php $ username = filter_input(INPUT_POST,'username'); $ email = filter_input(INPUT_POST,'email'); $ mobile = filter_input(INPUT_POST,'mobile'); $ subject = filter_input(INPUT_POST,'subject'); if(!empty($ username)) { //检查名称是否仅包含字母和空格 if(!preg_match(/ ^ [a-zA-Z] * $ /,$ username)){ echo只允许字母和空格; } if(!empty($ email)) { if(!filter_var($ email) ,FILTER_VALIDATE_EMAIL)){ echo电子邮件格式无效; } if(!empty($ mobile)) { if(!preg_match(/ ^ [0-9] {10} $ /,$ mobile)){ echo手机号码无效; } if(!empty($ subject)) { if(preg_match(/ ^ [0-9] {10} $ /,$ subject)){ echo无效数据; } $ host =localhost; $ dbusername =root; $ dbemail = email; $ dbmobile =mobile; $ dbsubject =subject; $ dbname =contactphpdem; //创建连接 $ conn = new mysqli($ host,$ dbusername,$ dbemail,$ dbmobile,$ dbsubject,$ dbname ); if(mysqli_connect_error()){ die('Connect Error('。mysqli_connect_errno()。')'br /> .mysqli_connect_error()); } else { $ sql =INSERT INTO contactphpdem(用户名,电子邮件) ,移动,主题) 值('$ username','$ email','$ mobile','$ subject'); if($ conn- >查询($ sql)) { echoalert('你的成功输入'); echo窗口。 open('Home.html','_ self'); } else { echo错误:。 $ sql。。 $ conn->错误; } $ conn-> close(); } } 其他 { echo请与我们分享您的想法或查询以改善我们的服务; die(); } } else { echo请输入您的手机号码; die(); } } else { echo请输入您的电子邮件ID; die(); } } else { echo名字不应为空; die(); } ?>Warning: mysqli::__construct() expects parameter 5 to be integer, string given in C:\xampp\htdocs\project\contactdemo.php on line 35Warning: mysqli::query(): Couldn't fetch mysqli in C:\xampp\htdocs\project\contactdemo.php on line 44Warning: main(): Couldn't fetch mysqli in C:\xampp\htdocs\project\contactdemo.php on line 50Error:INSERT INTO contactphpdem(username,email,mobile,subject) values('Rahul','[email protected]','8105189061','nvjmlik')Warning: mysqli::close(): Couldn't fetch mysqli in C:\xampp\htdocs\project\contactdemo.php on line 52What I have tried:<?php$username= filter_input(INPUT_POST,'username');$email= filter_input(INPUT_POST,'email');$mobile= filter_input(INPUT_POST,'mobile');$subject= filter_input(INPUT_POST,'subject');if(!empty($username)){ // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$username)) { echo "Only letters and white space allowed"; }if(!empty($email)){ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo "Invalid email format"; }if(!empty($mobile)){ if (!preg_match("/^[0-9]{10}$/",$mobile)) { echo "Invalid mobile number"; } if(!empty($subject)){if (preg_match("/^[0-9]{10}$/",$subject)) { echo "Invalid data"; }$host="localhost";$dbusername="root";$dbemail="email";$dbmobile="mobile";$dbsubject="subject";$dbname="contactphpdem";//Create connection$conn = new mysqli($host,$dbusername,$dbemail,$dbmobile,$dbsubject,$dbname);if(mysqli_connect_error()){die('Connect Error('. mysqli_connect_errno().') '. mysqli_connect_error());}else{$sql = "INSERT INTO contactphpdem(username,email,mobile,subject)values('$username','$email','$mobile','$subject')";if($conn->query($sql)){echo"alert('Your are Successfully entered')";echo"window.open('Home.html','_self')";}else{echo"Error:". $sql ."". $conn->error;}$conn->close(); }}else{echo"Please share your thoughts or query for us to improve our service";die();}}else{echo"Please enter your mobile number";die();}}else{echo"Please enter your email id";die();}}else{echo"Name should not be empty";die();}?>推荐答案 username = filter_input(INPUT_POST,'username');username= filter_input(INPUT_POST,'username'); email = filter_input(INPUT_POST,'email');email= filter_input(INPUT_POST,'email'); mobile = filter_input(INPUT_POST,'mobile');mobile= filter_input(INPUT_POST,'mobile'); 这篇关于致命错误:未捕获错误:调用C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\第2行的\project\r.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-04 21:00