Yahoo奇摩知識+ 將於 2021 年 5 月 4 日 (美國東部時間) 終止服務。自 2021 年 4 月 20 日 (美國東部時間) 起,Yahoo奇摩知識+ 網站將會轉為唯讀模式。其他 Yahoo奇摩產品與服務或您的 Yahoo奇摩帳號都不會受影響。如需關於 Yahoo奇摩知識+ 停止服務以及下載您個人資料的資訊,請參閱說明網頁。
PHP寫入資料庫問題
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\apply.php on line 26
Query failed:Table 'all_data.member' doesn't exist
這是怎回事呢~~我哪裡設定錯了呢
以下是我程式碼:
<?
/* start session */
session_start();
/*Receive the data from form by POST */
$account = $_POST['account'];
$pass = $_POST['pass'];
$name = $_POST['name'];
$address = $_POST['address'];
$phone=$_POST['phone'];
/* Open a connection to a MySQL server */
$link = mysql_connect("localhost","root","014207");
if (!$link) {
die('Could not connect: '.mysql_error());
}
/* for big-5 display and save */
//mysql_query("SET NAMES 'Big5'");
/*Select a MySQL database */
mysql_select_db("all_data") or die("Could not select databsase all_data");
/*Is there the same lecture in the database? */
$query = "select account from members where account = '$account'";
$result=mysql_query($query);
$num_rows = mysql_num_rows($result);
if ($num_rows != 0)
{
$act= $account."帳號重複!";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>無標題文件</title>
</head>
<body>
<?
}
else
{
/* register the variable of session */
session_register("user");
/* assign the value of variable of session */
$_SERVER["user"]=$account;
/*Insert a MySQL query */
$query="INSERT INTO member (account,pass,name,phone,address) VALUES ('$account','$pass',$name,$phone,$address)";
$result=mysql_query($query) or die("Query failed:".mysql_error());
?>
<?
exit;
}
mysql_free_result($result);
mysql_close($link);
?>
</body>
</html>
資料表示MENBER
宣告變數$act,但沒有echo,看不出有何作用.
我這只是要看看可不可以寫入資料庫而已
不管我把資料表改成MENBER或者MENBERS他都出現相同錯誤
所以我不知道我哪裡設定錯誤了
1 個解答
- k7800kLv 51 0 年前最佳解答
------$act= $account."帳號重複!";
宣告變數$act,但沒有echo,看不出有何作用.
-------$query="INSERT INTO member (account,pass,name,phone,address) VALUES ('$account','$pass',$name,$phone,$address)";
資料表是member還是members搞清楚,還是根本就沒有資料表.
VALUES內的後三個變數沒加單引號.
2007-12-19 09:30:15 補充:
它的錯誤訊息就是member這個資料表不存在.
而你說資料表是menber,一個是m一個是n,若訊息相同仍然是資料表名稱問題.字母錯了或大小寫不同.