我想在2個PHP頁面中使用2個變量的內容,但是我無法使它工作。php/mysql變量
$connect = mysql_connect('localhost', 'username', 'password');
if(!$connect)
{
die('Could not connect to the database: ' . mysql_error());
}
mysql_select_db("database", $connect);
$id = $lastid; // in the page I created this variable i have: $lastid = mysql_insert_id()
$code = $random; // in the page I created this variable i have: $random = rand(123456789,98765432);
if($id&&$code)
{
$check= mysql_query('SELECT * FROM members WHERE id= "$id" AND random = "$code"');
$checknum = mysql_num_rows('$check');
if($checknum == '1') // run query to activate the account
{
$acti= mysql_query('UPDATE members SET activation = "1" WHERE id= "$id"');
die('Your account has been activated. You may now log in!');
}else{
die('Invalid id or activation code.');
}
}else{
die('Could not either find $id or $code!');
}
?>
我會被罰款,如果我能我的新網頁上使用mysql_insert_id()
,但mysql_insert_id()
如果我不改變數據庫無法正常工作。
你究竟在哪裏設置了'$ lastid'和'$ random'? – JJJ
究竟是不是工作?你有什麼錯誤嗎? – knittl
你在找[Sessions](http://php.net/manual/en/book.session.php)嗎? – str