我在尝试连接到我的 mysql 数据库时遇到错误,我是一个 PHP/mysql 爱好者,所以我希望你们能帮助我,因为我被卡住了。
Warning: mysql_query() [function.mysql-query]:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'\
(2) in /public/sites/www.kernlab.nl/website/index.php on line 13
Warning: mysql_query() [function.mysql-query]: A link to the server could not be
established in /public/sites/www.kernlab.nl/website/index.php on line 13
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
以下是我尝试连接到我的数据库的方法:
<?php
$db_host = "host";
$db_username = "user";
$db_password = "pass";
$db_database = "db";
$link = mysqli_connect($db_host,$db_username,$db_password) or die("Cannot connect");
mysqli_select_db($link, $db_database) or die("Cannot select database");
?>
这就是我尝试回显数据的方式:
<?php
$query="SELECT * FROM ditdoenweblokken ORDER BY id DESC";
$result = mysql_query($query) or die(mysql_error()) ;
while($rij = mysql_fetch_array($result)){
?>
<li><a style="height:150px;width:150px;" class="fancybox" href="#inline<?php echo($rij['id']);?>">
<p style="font-weight:bold;"><?php echo($rij['titel']);?></p>
<?php echo($rij['quote']);?></a>
</li>
<?php
}
?>
我觉得问题不在于脚本本身,而在于 mysql 服务器的某个地方?希望你们能帮忙,因为我被卡住了。
提前致谢