我不久前继承了一个WordPress网站,该网站通过insert_php插件添加了一些自定义代码。它运行得很好,显然是我没有意识到的他们网站的重要组成部分。我不是程序员,只是所有行业IT人员的杰作。 无论如何,我注意到最基本的MySQL命令可以用“ i”修复,并且mysqli_connect命令现在将接受dbname的第4个参数。我不确定在哪里截断代码 它非常小,使用WordPress短代码(我将创建一个(真实的代码段))。 我还阅读了查询,并且fetch_array遥遥无期。 有什么建议吗? 这是我的东西:
$con = mysql_connect("127.0.0.1","123xxxxxxx","4444444444444");
if (!$con) {
die("Can not connect:" . mysql_error());
}
mysql_select_db("dbxxxxx",$con);
$sql = 'SELECT * FROM EmployeeTable where PrimaryCampusPerson="Yes" order by SchoolDistrict, Site';
$myData = mysql_query($sql,$con);
echo "
";
while($record = mysql_fetch_array($myData)){
echo "
";
echo "";
echo "
";
echo "
";
echo "
";
}
echo "
Campus District Program Manager
" . "" . $record['Site'] . "" . "
" . $record['WorkAddress'] . "
" . $record['WorkCity'] . $record['WorkState'] . $record['WorkZip'] ."
" . $record['SchoolMainPhone'] ." " . $record['SchoolDistrict'] . " " . "" . $record['LastName'] . ", " . $record['FirstName'] . "" . "
" . $record['WorkCISPhone'] ."
" . "". $record['Email'] . "" ."
";
[/insert_php]````
答案 0 :(得分:0)
$con = mysqli_connect("127.0.0.1", "123xxxxxxx", "4444444444444", "dbxxxxx");
// if there's an error connecting to db
if (mysqli_connect_errno()) {
echo "Failed to connect: " . mysqli_connect_errno();
}
$sql = "SELECT * FROM EmployeeTable
WHERE PrimaryCampusPerson = "Yes"
ORDER BY SchoolDistrict, Site";
$myData = mysqli_query($con, $sql);
while ($record = mysqli_fetch_array($myData)) {
// echo db output
}
答案 1 :(得分:0)
$con = mysql_connect("127.0.0.1","123xxxxxxx","4444444444444");
mysql_select_db("dbxxxxx",$con);
以上两行可以合并为
$con=mysqli_connect("127.0.0.1","123xxxxxxx","4444444444444","dbxxxxx")
对于mysql查询mysql_query($sql,$con);
mysqli _query以connce作为第一个参数
mysqli_query($con,$sql);
对于mysql_fetch_array($myData)
,您可以使用
mysqli_fetch_array($myData)