在xampp中安装DVWA时出错

当我试图打开localhost/dvwa,我得到这个:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\dvwa\dvwa\includes\dvwaPage.inc.php:461 Stack trace: #0 C:\xampp\htdocs\dvwa\login.php(8): dvwaDatabaseConnect() #1 {main} thrown in C:\xampp\htdocs\dvwa\dvwa\includes\dvwaPage.inc.php on line 461

如果我点击localhost/dvwa/setup.php,我会看到数据库设置但当我点击Create/Reset database,我会看到这个

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\dvwa\dvwa\includes\DBMS\MySQL.php:9 Stack trace: #0 C:\xampp\htdocs\dvwa\setup.php(17): include_once() #1 {main} thrown in C:\xampp\htdocs\dvwa\dvwa\includes\DBMS\MySQL.php on line 9 

我已经更改了$ _DVWA ['db_password'] =''; 和我的config.inc.php看起来像这样

<?php

# If you are having problems connecting to the MySQL database and all of the variables below are correct
# try changing the 'db_server' variable from localhost to 127.0.0.1. Fixes a problem due to sockets.
#   Thanks to @digininja for the fix.

# Database management system to use
$DBMS = 'MySQL';
#$DBMS = 'PGSQL'; // Currently disabled

# Database variables
#   WARNING: The database specified under db_database WILL BE ENTIRELY DELETED during setup.
#   Please use a database dedicated to DVWA.
$_DVWA = array();
$_DVWA[ 'db_server' ]   = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ]     = 'root';
$_DVWA[ 'db_password' ] = '';

# Only used with PostgreSQL/PGSQL database selection.
$_DVWA[ 'db_port '] = '5432';

# ReCAPTCHA settings
#   Used for the 'Insecure CAPTCHA' module
#   You'll need to generate your own keys at: https://www.google.com/recaptcha/admin/create
$_DVWA[ 'recaptcha_public_key' ]  = '';
$_DVWA[ 'recaptcha_private_key' ] = '';

# Default security level
#   Default value for the secuirty level with each session.
#   The default is 'impossible'. You may wish to set this to either 'low', 'medium', 'high' or impossible'.
$_DVWA[ 'default_security_level' ] = 'impossible';

# Default PHPIDS status
#   PHPIDS status with each session.
#   The default is 'disabled'. You can set this to be either 'enabled' or 'disabled'.
$_DVWA[ 'default_phpids_level' ] = 'disabled';

# Verbose PHPIDS messages
#   Enabling this will show why the WAF blocked the request on the blocked request.
#   The default is 'disabled'. You can set this to be either 'true' or 'false'.
$_DVWA[ 'default_phpids_verbose' ] = 'false';

?>
dongsong73032
dongsong73032 可能重复的PHP/Apache:PHP致命错误:调用未定义的函数mysql_connect()
4 年多之前 回复

1个回答



您必须在 php.ini </ code>中启用MySQL扩展。 查看 PHP文档。</ p>

您有 在 php中取消注释包含 extension = php_mysql.dll </ code>(适用于Windows上的PHP)或 extension = mysql.so </ code>(适用于Linux上的PHP)的行。 INI </代码>。 如果您将PHP与Web服务器一起使用,请不要忘记在 php.ini </ code>中进行任何更改后重新启动它。</ p>

在Linux上你有可能 必须首先安装扩展名:</ p>

  sudo apt-get install php5-mysql 
</ code> </ pre>

安装也应该 自动启用扩展,因此您不必启用 php.ini </ code>。 安装后重新启动Web服务器。</ p>
</ div>

展开原文

原文

You have to enable the MySQL extension in php.ini. Check PHP documentation.

You have to uncomment line, which contains extension=php_mysql.dll (for PHP on Windows) or extension=mysql.so (for PHP on Linux) in your php.ini. If you're using PHP with a web server, don't forget to restart it after any change in php.ini.

It's possible that on Linux you will have to install the extension first:

sudo apt-get install php5-mysql

Installation should also enable the extension automatically, so you don't have to enable it the php.ini. Restart the web server after installation.

duanquezhan7268
duanquezhan7268 检查phpinfo函数的输出。
4 年多之前 回复
duanbei7005
duanbei7005 我在哪里找到php.ini?。 我顺便坐在窗户里
4 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问