0
我想連接到MySQL數據庫的第一次。你能看到下面哪些工作不正常嗎? 我收到第3行的錯誤。 我的服務器地址從Godaddy到我的數據庫會是什麼樣子?我在控制面板中找到了該地址。無法連接到MySQL數據庫
感謝您的任何幫助。之前從未使用PHP進行編程。
<body>
<?php
$con = mysql_connect("MydbName.db.3924516.hostedresource.com ","Userid","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM Gallerys");
echo "<table border='1'>
<tr>
<th>Thumb Url </th>
<th>Gallery Url</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['THUMBURL'] . "</td>";
echo "<td>" . $row['GALLERYURL'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
</body>
由於您剛剛瞭解到'mysql_ *',因此我不想破壞您的泡泡,但該擴展程序處於預先棄用階段,至少您需要找到一個使用' mysqli'擴展名或'PDO'。並確保它提到「準備好的陳述」。因爲如果教程沒有,它就是垃圾。 – rdlowrey
你得到的錯誤信息是什麼? –
謝謝我找那個教程。 – CsharpBeginner