php - 为什么我不断收到错误 500 (mySQL)?

标签 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); 

 ?>

最佳答案

改变

print mysql_error($link)

print mysql_error($link);
                        ^

关于php - 为什么我不断收到错误 500 (mySQL)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16431875/

相关文章:

php - 表单数据库设计

android - ClearableEditText - requestLayout() 在 Android 4.3 上调用不当

php - Nginx:读取上游时 readv() 失败(104:对等连接重置)

php - 使用 ON DUPLICATE KEY UPDATE 更新表时出错

mysql - JSF 托管 bean 中的 SQL WHERE LIKE 子句

php - SQLSTATE[23000] : Integrity constraint violation: 1048 Column 'name' cannot be null

swift - 如何在 `NSURLSession` 超时时显示错误并终止应用程序?

database - 如何摆脱#func!出现在MS Access的查询表中?

php - mariadb 使用什么 PDO 驱动程序?

mysql - Galera Cluster 为断开连接的节点启用了数据库写入