$query = mysql_query("SELECT * FROM joblist WHERE salary LIKE '%$searchq%' OR jobtitle LIKE '%$searchq%'");
$count = mysql_num_rows($query);
if ($count == 0){
$output = 'There was no search results!';
}else {
while($row = mysql_fetch_array($query)) {
$salary = $row['$salary'];
$jobtitle = $row['$jobtitle'];
$id = $row['id'];
$output .= '<div>' .$salary.' '.$jobtitle.'</div>';
}
}
致命错误:
Call to undefined function mysql_query() in /srv/http/head.php on line 16
答案 0 :(得分:2)
如果您使用的是PHP 7,则可以使用mysqli_ *。因为此版本中没有mysql_ *。以下是您可以使用它的示例。
<?php
// procedural style of mysqli
$host = "host";
$user = "user";
$password = "password";
$database = "db";
$link = mysqli_connect($host, $user, $password, $database);
if(!$link){
echo ('unable to connect to database');
}
else {
$sql = "your select query";
$result = mysqli_query($link,$sql);
if(mysqli_num_rows($result) == 1){
// SUCCESS STUFF
}
else {
// error stuff
}
} // end else
?>
答案 1 :(得分:1)
Mysql_ *从PHP 7.0起已弃用。请使用mysqli_ *。 否则,将您的PHP版本降级到5.6或更低版本。它将正常工作。 https://www.php.net/manual/en/function.mysql-connect.php(请参阅本页的衰落部分)。
答案 2 :(得分:0)
系统上未安装/配置mysql的PHP扩展。
尝试
Your PHP installation appears to be missing the MySQL extension which is required by WordPress以确保模块实际已启用
在Linux上安装Ubuntu http://www.cyberciti.biz/faq/install-mysql-php-support-for-wordpress/
Windows PHP doesn't see mysql extension
这就是说,你应该使用 mysqli (不是 mysql )扩展名,因为 mysql 已被弃用,不推荐使用,并且不在PHP7。