gpt4 book ai didi

php - mysql_num_rows();不会发帖

转载 作者:行者123 更新时间:2023-11-29 11:34:52 24 4
gpt4 key购买 nike

我正在注册,我想检查用户名是否被使用,不知道为什么 mysql_num_rows();函数不会发布任何内容

<?php
if(isset($_POST['name_signup'])) {
if($_POST['pass_signup']==$_POST['pass_a_signup']){
$select=mysql_num_rows(mysql_query("SELECT * FROM users WHERE nick='".$_POST['nick_signup']."'"));
if($select=!0){
$name=$_POST['name_signup'];
$secondname=$_POST['secondname_signup'];
$nick=$_POST['nick_signup'];
$pass=$_POST['pass_signup'];
$mail=$_POST['email_signup'];
$passx=md5(md5($pass));
include 'db.php';
mysql_query("INSERT INTO users(firstname,secondname,nick,pass,email,date)VALUE('".$name."','".$secondname."','".$nick."','".$passx."','".$mail."',NOW())");
echo "Succesfully Signed up";
echo'<meta http-equiv="refresh" content="3;URL=../index.php">';
}else {
echo "Username used";
echo'<meta http-equiv="refresh" content="3;URL=../index.php?page=signup">';
}
}
else{
echo'Passwords do not match';
echo'<meta http-equiv="refresh" content="1;URL=../index.php?page=signup">';
}
}

else {
echo'<meta http-equiv="refresh" content="0;URL=../index.php">';
}
?>

最佳答案

mysql 扩展已被弃用,您应该停止使用它。请尝试 mysqliPDO

您的代码中存在一个错误:

if($select=!0){

你应该像这样更正它:

if($select!=0){

再次,停止使用mysql。并开始使用准备好的语句,否则您的代码将面临 SQL 注入(inject)的危险

关于php - mysql_num_rows();不会发帖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36792970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com