Dbmier LED Artcraft Tracing Light Pad Light Box Light Board Light Table- A4

PHP Tech Blog

Dbmier LED Artcraft Tracing Light Pad Light Box Light Board Light Table- A4

留言簿(5)

Links

My Favorites

推荐技术文章

阅读排行榜

评论排行榜

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

<?php
ob_start();
$host="localhost"; // Host name
$username="****"; // Mysql username
$password="****"; // Mysql password
$db_name="users"; // Database name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Define $email and $password
$email= $_POST['email'];
$password= md5($_POST['password']);

$check="SELECT * FROM 'login' WHERE 'email'='$email' and 'password'='$password'";
$result=mysql_query($check);

// Mysql_num_row is counting table row
$count = mysql_num_rows($result); // This is line 20 where it keeps complaining.

// If result matched $email and $password, table row must be 1 row

if($row==1){
// Register $email, $password and redirect to file "login_success.php"
session_register("email");
session_register("password");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}

ob_end_flush();
?>

I have spent around 3 hours trying to fix the problem, and trawling through many google sites. I cannot find what the problem is. Any help would be much appreciated.


Answer this Question

$check="SELECT * FROM 'login' WHERE 'email'='$email' and 'password'='$password'";

Don't use 'single quotes' around identifiers for tables/columns, use `back quotes` instead.

OR
最后查出来的结论是我的SQL语句FROM后面只写了table的名字,没写database的名字,加上之后就好了。
SELECT * FROM DB_NAME.TABLE WHERE... ...

posted on 2009-05-18 11:45 haix 阅读(1935) 评论(0)  编辑 收藏 引用 网摘 所属分类: MYSQL


只有注册用户登录后才能发表评论。
网站导航:
Dbmier LED Artcraft Tracing Light Pad Light Box Light Board Light Table- A4