/*
$sql:查询数据库的SQL语句
$find_table:需要检查的表名
*/
mysql_connect('localhost','root','2260375') or die('can\'t not connect database')
if((int)check_table_is_exist('show databases','test')==1)
{
echo '该表存在'
}
else
{
echo '该表不存在'
}
function check_table_is_exist($sql,$find_table)
{
$row=mysql_query($sql)
$database=array()
$finddatabase=$find_table
while ($result=mysql_fetch_array($row,MYSQL_ASSOC))
{
$database[]=$result['Database']
}
unset($result,$row)
mysql_close()
/*开始判断表是否存在*/
if(in_array($find_table,$database))
{
return true
}
else
{
return false
}
}
?>
$conn = mysql_connect("localhost","root","")mysql_select_db("homework", $conn)
mysql_query("SET NAMES 'UTF8'",$conn)
$username=$_POST['user_email']
$password=$_POST['password']
$sql = "select * from user where username='$username' and password='$password'"
$Result = mysql_query($sql, $conn)
$onerow = mysql_fetch_array($Result)
if ( $onerow )
echo "正确"
else
echo "错误"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)