我想使用php從mysql表中獲取數據。請,誰能告訴我?這段代碼有什麼問題?什麼是正確的代碼,以從MySQL數據庫獲取數據:我怎樣才能從數據庫獲取數據在PHP中使用MySQL?
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$connect=mysql_connect("localhost","root","");
// connect to databsase
mysql_select_db("form1",);
enter code here
// query the database
$query = mysql_query("SELECT * FROM users WHERE name = 'Admin' ");
// fetch the result/convert resulte in to array
WHILE ($rows = mysql_fetch_array($query)):
$rows = $rows['Name'];
$address = $rows['Address'];
$email = $rows['Email'];
$subject = $rows['Subject'];
$comment = $rows['Comment']
echo "$Name<br>$Address<br>$Email<br>$Subject<br>$Comment<br><br>";
endwhile;
?>
什麼錯誤,你得到些什麼? – amitchhajer 2013-02-12 07:19:19
您正在使用[an **過時的**數據庫API](http://stackoverflow.com/q/12859942/19068)並應使用[現代替換](http://php.net/manual/en/ mysqlinfo.api.choosing.php)。 – Quentin 2013-02-12 07:19:59
當你使用'mysql_connect(「localhost」,「root」,「」);''時,聲明上述變量的原因是什麼?並告訴我們你從這段代碼中得到的結果 – 2013-02-12 07:21:06