为什么我一直收到错误500(mySQL)?

时间:2013-05-08 02:48:22

标签: php mysql error-handling connection

我使用以下php脚本:

<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
$link = mysql_connect('mywebsite', 'login', 'password'); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
echo 'Connected successfully';
//Until here, everything is PERFECT, the Connection is established.

//The following piece of code spits out error 500: 
mysql_select_db("rates"); 
$query = "SELECT * FROM `table1` WHERE `RateName` LIKE '%res%'"; 
if ($r=mysql_query($query, $link)) {

while ($row=mysql_fetch_array($r)) {
print "<p><h3>{$row['UtilityName']}>/h3>
{$row['RateName']}<br />
</p><hr />\n";
}
}
else {
print mysql_error($link)
}

mysql_close($link); 

 ?>

1 个答案:

答案 0 :(得分:3)

更改

print mysql_error($link)

print mysql_error($link);
                        ^