这个错误是什么意思?
"不推荐使用:mysql_pconnect():不推荐使用mysql扩展 将来将被删除:使用mysqli或PDO代替 C:\ wamp \ www \ Myren \ Connections \ localhost.php在线"?
答案 0 :(得分:1)
"此错误意味着什么?"
"不推荐使用:mysql_pconnect():不推荐使用mysql扩展,将来会删除:在线路上使用mysqli或PDO代替C:\ wamp \ www \ Myren \ Connections \ localhost.php&#34 ;
安装Wampserver时,目前附带PHP版本5.5.12,如果使用基于mysql_
的代码,则该版本的PHP会引发注意。
您需要将mysql_
的所有实例更改为mysqli_
(或使用PDO)。
旁注: mysqli_
需要传递数据库连接参数。
我知道这是因为我自己最近在我的一台PC上安装了Wampserver,并且运行了安装中包含的测试SQL脚本时出现了相同的错误消息。已经知道错误是什么,很快就能解决问题。
因此,例如:(更改以下内容)......
<?php
// Connecting, selecting database
$link = mysql_connect('localhost', 'username', 'password_if_any')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('your_database') or die('Could not select database');
// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
需要更改为:
<?php
// Connecting, selecting database
$link = mysqli_connect('localhost', 'username', 'password_if_any', 'your_DB')
or die('Could not connect: ' . mysqli_error($link));
echo 'Connected successfully';
// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysqli_query($link, $query)
or die('Query failed: ' . mysqli_error($link));
// Printing results in HTML
echo "<table>\n";
while ($line = mysqli_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysqli_free_result($result);
// Closing connection
mysqli_close($link);
?>
答案 1 :(得分:0)
这意味着用于在PHP中连接和使用MySQL的函数是旧的(不推荐使用)。您应该切换到mysqli_connect或PDO等功能,就像错误消息所示。
答案 2 :(得分:0)