我需要使用php和mysql顯示記錄的幫助。我的知識非常基礎,儘管我可以正確閱讀和解讀代碼。我目前正在開發一個網站使用Joomla作爲CMS ..我需要PHP的自定義代碼來顯示我的MySQL數據庫中的表的記錄內容。需要顯示記錄的幫助
這裏的代碼..我給了帳戶的正確的細節,但然後我無法訪問它。
$user_name = "kansai_ksadmin";
$password = "sample123";
$database = "kansai_ksdb";
$server = "localhost";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$SQL = "SELECT jos_djcf_categories.name AS category, jos_djcf_items.name AS title, jos_djcf_items.description FROM jos_djcf_categories INNER JOIN jos_djcf_items ON jos_djcf_categories.id = jos_djcf_items.cat_id";
$result = mysql_query($SQL);
while ($db_field = mysql_fetch_assoc($result)) {
print $db_field['category'] . "<BR>";
print $db_field['title'] . "<BR>";
print $db_field['description'] . "<BR>";
}
mysql_close($db_handle);
}
else {
print "Database NOT Found ";
mysql_close($db_handle);
}
這裏的錯誤
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'kansai_ksadmin'@'localhost' (using password: YES) in /home/kansai/domains/kansaiscene.com/public_html/beta/modules/mod_php/mod_php.php(36) : eval()'d code on line 9
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/kansai/domains/kansaiscene.com/public_html/beta/modules/mod_php/mod_php.php(36) : eval()'d code on line 10
Database NOT Found
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /home/kansai/domains/kansaiscene.com/public_html/beta/modules/mod_php/mod_php.php(36) : eval()'d code on line 23
我需要解決此問題... 謝謝幫助!
「拒絕訪問」是不是一種編程問題。 – 2011-03-09 06:47:29
您是否能夠使用mysqladmin使用這些憑證訪問數據庫? – rkg 2011-03-09 06:48:14
btw你應該使用Joomla!的dtabase類,用'$ db =&Jfactory :: getDBO()'實例化它,所以你不會遇到這種問題。這是v。1.5.x,你使用這個還是1.6? – 2011-03-09 06:52:36