你好,stackoverflow的人。我需要幫助我的腳本。我有註冊文件和索引文件,當我索引文件的情況下,當行動是註冊,加載registration.php標題,(index.php?action = register)我的註冊腳本不起作用!我得到錯誤,找不到變量mysql(在register.inc.php文件中)。但是,當URL是正常的 - www.website.com/register.php然後一切正常,你們知道這是什麼樣的問題?我該如何解決它?URL和mysqli中的問題
這裏是我的register.in.php文件起始:
<?php
include_once 'db_connect.php';
include_once 'psl-config.php';
$error_msg = "";
if (isset($_POST['username'], $_POST['email'], $_POST['p'])) {
// Sanitize and validate the data passed in
$username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
// Not a valid email
$error_msg .= '<p class="error">The email address you entered is not valid</p>';
}
$password = filter_input(INPUT_POST, 'p', FILTER_SANITIZE_STRING);
if (strlen($password) != 128) {
// The hashed pwd should be 128 characters long.
// If it's not, something really odd has happened
$error_msg .= '<p class="error">Invalid password configuration.</p>';
}
$prep_stmt = "SELECT id FROM members WHERE email = ? LIMIT 1";
$stmt = $mysqli->prepare($prep_stmt);
錯誤是最後一排,其中$庫MySQLi英寸$ mysql來自文件do_connect.php:
<?php
include_once 'psl-config.php';
$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
請幫忙嗎?
爲什麼包含這個psl-config.php時,它已經包含在db_connect.php' –
在這裏寫完整的錯誤! –
這裏是錯誤'注意:未定義變量:mysqli in/home /....../public_html/includes/register.inc.php on line 30 致命錯誤:調用成員函數prepare()第30行的/home........../public_html/includes/register.inc.php中的非對象# – McLaren