[英]mysql_query is not working as expected
$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>';
}
}
Fatal error:致命错误:
Call to undefined function mysql_query() in /srv/http/head.php on line 16
You can use mysqli_* if you are using PHP 7. Because mysql_* is not available in this version.如果您使用的是 PHP 7,则可以使用 mysqli_*。因为 mysql_* 在此版本中不可用。 Here is the example that you can use it.
这是您可以使用它的示例。
<?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
?>
Mysql_* has been depreciated from PHP 7.0 and onwards. Mysql_* 已从 PHP 7.0 及更高版本开始折旧。 Please use mysqli_*.
请使用 mysqli_*。 Or else downgrade your PHP version to 5.6 or lower.
或者将您的 PHP 版本降级到 5.6 或更低。 It will work fine.
它会正常工作。 https://www.php.net/manual/en/function.mysql-connect.php ( see the waning section of this page).
https://www.php.net/manual/en/function.mysql-connect.php (见本页的减弱部分)。
The PHP extension for mysql is not installed/configured on your system.您的系统上未安装/配置 mysql 的 PHP 扩展。
Try尝试
Your PHP installation appears to be missing the MySQL extension which is required by WordPress to ensure the module is actually enabled 您的 PHP 安装似乎缺少 WordPress 所需的 MySQL 扩展,以确保该模块实际启用
Install on Linux Ubuntu http://www.cyberciti.biz/faq/install-mysql-php-support-for-wordpress/在 Linux Ubuntu 上安装http://www.cyberciti.biz/faq/install-mysql-php-support-for-wordpress/
Windows PHP doesn't see mysql extension Windows PHP 看不到 mysql 扩展
This being said, you should use mysqli (not mysql ) extension, as mysql is deprecated, not recommended and will be out of PHP7.话虽如此,您应该使用mysqli (而不是mysql )扩展名,因为mysql已被弃用,不推荐使用并且将脱离 PHP7。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.