具体代码:<?phprequire ("mysqlConn.php");require("Register.php");var_dump(Register::insertUser("留意","1234567"));?>mysqlConn代码:<?php //数据库连接文件$conn=mysql_connect...
具体代码:
require( "mysqlConn.php" );
require( "Register.php" );
var_dump(Register::insertUser( "留意", "1234567" ));
?>
mysqlConn代码:
//数据库连接文件
$conn = mysql_connect( "localhost", "root", "123456" );
mysql_select_db( "dbtest", $conn );
?>
Register代码:
class Register
{
//插入用户数据
static function insertUser( $userName, $userPwd )
{
$judgeLink = mysql_query( "select count(username) from exeruser where username='{$userName}'" );
echo "select count(username) from exeruser where username='{$userName}'"; //查看select语句是否有误
$judge = mysql_fetch_row( $judgeLink );
var_dump($judge); //查看返回的具体结果
if( $judge[0] )
{
return "有相同用户名!";
}
return mysql_query( "insert into exeruser(username,pwd) values( {$userName},{$userPwd} )" );
}
运行后的具体结果:
select count(username) from exeruser where username='留意'array(1) { [0]=> string(1) "0" } bool(false)
展开