我无法将php连接到数据库,我在Windows中使用xampp,味精:
致命错误:无法在写入上下文中使用函数返回值
代码:
<?php
define('ENV_LOCAL_URL') = 'localhost';
if(strstr(filter_input(INPUT_SERVER, 'SERVER_NAME'), ENV_LOCAL_URL)) {
define('ENVIRONMENT', 'DEV');
error_reporting(E_ALL);
ini_set('display_errors', 'On');
} else {
define('ENVIRONMENT', 'LIVE');
}
$errors = [];
define('ENTRY_CODE', 'password'); // App's password
define('COOKIE_ACCESS_NAME', 'appAccess');
define('COOKIE_ACCESS_VALUE', 's0d983rh203983');
define('COOKIE_EXPIRE', 60*60*24); // 1 day
define('COOKIE_GROUP_ID', 'appGroId');
define('COOKIE_REDIRECTION_NAME', 'appRedSit');
define('ANSWERS_QTY', '3'); // Quantity of questions
define('ANSWER_1', '2'); // Question's correct answer
define('ANSWER_2', '2'); // Question's correct answer
define('ANSWER_3', '2'); // Question's correct answer
define('ANSWER_POINTS', '1'); // Points for each correct answer
define('DIR', realpath(__DIR__.DIRECTORY_SEPARATOR.'..'));
define('ROOT', '/');
define('DIR_IMG', ROOT.'img/');
define('DIR_VIEWS', DIR.DIRECTORY_SEPARATOR.'views/');
require 'database.php';
require 'classes/access_util.php';
require 'classes/group.php';
require 'classes/answer.php';
require 'classes/redirection_util.php';
和数据库页面:
$db_name = 'dbname'; // Database's name
$db_servername = "localhost"; // Database's server (default: localhost)
$db_username = "root"; // Database's user
$db_password = "a12345"; // Database's user's password
答案 0 :(得分:0)
php define()
方法可用于设置常量,但不能用于比较或使用=
设置。
尝试将define('ENV_LOCAL_URL') = 'localhost';
更改为define('ENV_LOCAL_URL', 'localhost');