我嘗試了以下編碼(帶有 HTML 的 PHP)來開發(fā)網(wǎng)站。它在 localhost 環(huán)境中運行良好。對于網(wǎng)絡(luò)托管,我在 Godaddy 購買了空間。我在 localhost 中使用 Ampps 服務(wù)器嘗試了此代碼,它以表格格式顯示內(nèi)容。我在 Godaddy 中成功上傳了內(nèi)容。但是沒有在現(xiàn)場訪問中獲得表。編碼mysql_connect("localhost", "root", "mysql")or die("cannot connect"); mysql_select_db("ex")or die("cannot select DB");# Prepare the SELECT Query$selectSQL = 'SELECT * FROM `volume1` where no=1';# Execute the SELECT Queryif( !( $selectRes = mysql_query( $selectSQL ) ) ){echo 'Retrieval of data from Database Failed - #'.mysql_errno().': '.mysql_error();}else{?><table border=1 border color=#e5e5e5 width=925><thead><tr><td style="font-size: 21px; font-weight: bold; color: #ffffff;" width="479" bgcolor="#ffffff" align="center"><span style="color: #000000; text-decoration: none;">Title/Author Name</span></td><td style="font-size: 21px; font-weight: bold; color: #ffffff;" width="29" bgcolor="#ffffff" align="center"><span style="color: #000000; text-decoration: none;">Pdf</span></td></tr></thead><tbody><?phpif( mysql_num_rows( $selectRes )==0 ){echo '<tr><td colspan="4">No Rows Returned</td></tr>';}else{while( $row = mysql_fetch_assoc( $selectRes ) ){?><tr><td> <font align="justify"><?phpecho "<font size=4 color=#0a0953>{$row['title']} </font> <br><font size=3 color=#07666e><br> {$row['author']}</font></td><td>\n";?></font><a href="images/pdf/<?php echo"{$row['pdf']}";?>.pdf" target="_blank"><img src ="images/pdf.jpg" height="40" width="40" /> </a></tr><?php }}?>
2 回答

HUH函數(shù)
TA貢獻1836條經(jīng)驗 獲得超4個贊
請在您的 GoDaddy 控制面板 -> MySQL 數(shù)據(jù)庫中創(chuàng)建一個數(shù)據(jù)庫,并在那里創(chuàng)建一個數(shù)據(jù)庫并將您的本地數(shù)據(jù)庫移動到這里。
此外,在您的 cPanel 中檢查您的 PHP 版本并根據(jù)需要進行更改。

慕村225694
TA貢獻1880條經(jīng)驗 獲得超4個贊
問題可能出在以下幾行:
mysql_connect("localhost", "root", "mysql")or die("cannot connect");
mysql_select_db("ex")or die("cannot select DB");
您看不到該表,因為其中沒有數(shù)據(jù)。
您將必須為 GoDaddy 數(shù)據(jù)庫查找/創(chuàng)建一個帳戶(也將一些數(shù)據(jù)放在那里),然后相應(yīng)地更改 mysql 名稱、密碼和數(shù)據(jù)庫。
編輯:mysql_*功能也已被棄用,mysqli_*如果可能,請改用。
- 2 回答
- 0 關(guān)注
- 141 瀏覽
添加回答
舉報
0/150
提交
取消