五个小时,我想,一行给我一个问题

问题描述 投票:0回答:1

这是我的第一次发布,我通常可以找到问题,是的,我对PHP有点陌生,并且大多数是Mysqil。因为我的记忆时间短,所以这变得更加困难...尝试了5个小时来解决此问题,所以请帮助我。

而且我知道这将是简单的逗号之类的东西……所以我们在这里

我正在使用Dreamweaver和phpMyAdmin

我正在尝试学习并制作注册表格/注册。

这是我得到的错误。

致命错误:未捕获错误:调用C:\ xampp \ htdocs \ login \ functions \ functions.php:207中未定义的函数qurey()堆栈跟踪:#0 C:\ xampp \ htdocs \ login \ functions \ functions。 php(161):register_user('Rebecca','Hunter','1234','rhunter419260 @ g ...','1234','1234','9108906865','81dc9bdb52d04dc ...')#1 C :\ xampp \ htdocs \ login \ register.php(8):validation_user_registration()#2 {main}放在第207行的C:\ xampp \ htdocs \ login \ functions \ functions.php中]

[注册/注册页面(register.php)是基本的:

    <?php include("includes/header.php") ?>

<?php include("includes/nav.php") ?>

    <div class="row">
        <div class="col-lg-6 col-lg-offset-3">

        <?php validation_user_registration();   ?>  

        </div>

    </div>
        <div class="row">
            <div class="col-md-6 col-md-offset-3">
                <div class="panel panel-login">
                    <div class="panel-heading">
                        <div class="row">
                            <div class="col-xs-6">
                                <a href="login.php">Login</a>
                            </div>
                            <div class="col-xs-6">
                                <a href="register.php" class="active" id="">Register</a>
                            </div>
                        </div>
                        <hr>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-12">
                                <form id="register-form" method="post" role="form" >

                                    <div class="form-group">
                                        <input type="text" name="first_name" id="first_name" tabindex="1" class="form-control" placeholder="First Name*" value="" required >
                                    </div>
                                    <div class="form-group">
                                        <input type="text" name="last_name" id="last_name" tabindex="1" class="form-control" placeholder="Last Name*" value="" required >
                                    </div>
                                    <div class="form-group">
                                        <input type="text" name="road_name" id="road_name" tabindex="1" class="form-control" placeholder="Road Name*"  required >
                                    </div>
                                    <div class="form-group">
                                        <input type="text" name="member_id" id="member_id" tabindex="1" class="form-control" placeholder="Member ID Number*" value="" required >
                                    </div>
                                    <div class="form-group">
                                        <input type="text" name="member_type" id="member_type" tabindex="1" class="form-control" placeholder="Member Type*" value="" required >
                                    </div>
                                    <div class="form-group">
                                        <input type="email" name="email" id="email" tabindex="1" class="form-control" placeholder="Email Address*" value="" required >
                                    </div>
                                    <div class="form-group">
                                        <input type="text" name="phone_number" id="phone_number" tabindex="1" class="form-control" placeholder="Phone Number(Optional)" value="">
                                    </div>                                  
                                    <div class="form-group">
                                        <input type="password" name="password" id="password" tabindex="2" class="form-control" placeholder="Password*" required>
                                    </div>
                                    <div class="form-group">
                                        <input type="password" name="confirm_password" id="confirm-password" tabindex="2" class="form-control" placeholder="Confirm Password*" required>
                                    </div>
                                    <div class="form-group">
                                        <div class="row">
                                            <div class="col-sm-6 col-sm-offset-3">
                                                <input type="submit" name="register-submit" id="register-submit" tabindex="4" class="form-control btn btn-register" value="Register Now">
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


<?php include("includes/footer.php") ?>

也是我的init.php

<?php ob_start();

session_start();

include("db.php");
include("functions.php");


?>

我认为我的数据库设置得很好。 (db.php)

<?php



$con = mysqli_connect('localhost', 'root', '', 'login_db');



//Count the rows in database
function row_count($result){

    return mysqli_num_rows($result);
}




function escape($string){
    global $con;


    return mysqli_real_escape_string($con, $string);
}

function query ($query) {

    global $con;

    return mysqli_query($con, $query);
}

function confirm($result){
    global $con;

    if(!$result) {

        die("QUERY FAILED" . mysqli_error($con));
    }
}

function fetch_array($result){
    global $con;

    return mysqli_fetch_array($result);
}

?>

该死的页面(functions.php)我无法上班。一路走来,我一直在测试。但是,当涉及到phpMyAdimn时,它开始变得混乱……现在我的额头因在桌子上敲头而受伤,所以为了我的健康,请救救我...大声笑

[这里有很多笔记,抱歉,这是我追踪的唯一方法。也许会帮助您了解我的想法!?

<?php

//////////// Helper Functions ////////////


//Clean user input char's
    function clean($string) {
        return htmlentities($string);
}
//Var for loccation
    function redirect($location){
        return header("Location: {location}");  
}

//To Echo messages later
    function set_message ($message){
        if(!empty($message)){
            $_SESSION['message'] = $message;
}
        else {
            $message = "";
}
}

//Echo the message
    function display_message(){
        if(isset($_SESSION['message'])){
            echo $_SESSION['message'];
            unset($_SESSION['message']);
        }
}

//Encrypt site forms hidden input
    function token_generator(){
        $token = $_SESSION['$token'] = md5(uniqid(mt_rand(), true));
    return $token;  
} 



function validation_errors($error_message){ /////// Happy Little Error Display /////// But makes // if($_SERVER['REQUEST_METHOD'] == "POST") { //// have a syntax error, unexpected quoted-string and white space (T- blah blah blah...)    NEED TO LOOK INTO LATER////

$error_message = <<<HTMLMESSAGE
    <div class="alert alert-warning alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <strong> Warning,</strong> $error_message
</div>
HTMLMESSAGE;    

return $error_message;

}

/// Insure there isn't double emails
function email_existst($email) {

    $sql = "SELECT id FROM users WHERE email = '$email'";

    $result = query($sql);
        if(row_count($result) ==1 ) {
            return true;
    }   else {
            return false;
    }
}

/// Insure there isn't double Road Name
function road_name_existst($road_name) {

    $sql = "SELECT id FROM users WHERE road_name = '$road_name'";

    $result = query($sql);
        if(row_count($result) ==1 ) {
            return true;
    }   else {
            return false;
    }
}


/////// End Helper Functions ///////


/////// Validation Functions ///////

function validation_user_registration(){

    $errors = [];

    $min = 3;
    $max = 20;

if($_SERVER['REQUEST_METHOD'] == "POST") { /// Why is this line red, still works... syntax error, unexpected quoted-string and white whitespace (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STING) ---- Line 45 seems to be the cause LOOK INTO LATER....    

        $first_name             = clean($_POST['first_name']);
        $last_name              = clean($_POST['last_name']);
        $road_name              = clean($_POST['road_name']);
        $email                  = clean($_POST['email']);
        $member_id              = clean($_POST['member_id']);
        $member_type            = clean($_POST['member_type']);
        $phone_number           = clean($_POST['phone_number']);
        $password               = clean($_POST['password']);
        $confirm_password       = clean($_POST['confirm_password']);

//First Name        
        if(strlen($first_name) < $min ) {
            $errors [] = "Your First Name cannot be less than {$min} characters";
}
        if(strlen($first_name) > $max ) {
            $errors [] = "Your First Name cannot be greater than {$max} characters";
}
//Last Name             
        if(strlen($last_name) < $min ) {
            $errors [] = "Your Last Name cannot be less than {$min} characters";
}
        if(strlen($last_name) > $max ) {
            $errors [] = "Your Last Name cannot be greater than {$max} characters";
}
//Member id ie: FM-1234     
        if(strlen($member_id) < $min ) {

            $errors [] = "Your Member-ID name cannot be less than {$min} characters";

}
        if(strlen($member_id) > $max ) {
            $errors [] = "Your Member-ID cannot be greater than {$max} characters";
}       
//Member type ie: Auxilary Member, Support Member, Full Member      
        if(strlen($member_type) < $min ) {

            $errors [] = "Your Member Type cannot be less than {$min} characters";

        }
        if(strlen($member_type) > $max ) {
            $errors [] = "Your Member Type cannot be greater than {$max} characters";
}
// Password Match
        if($password !== $confirm_password) {
            $errors [] = "Your password fields do not match";
}
//Email
        if(email_existst($email)) {
            $errors [] = "Sorry, this Email is alreay is registered. If you feel you have reach this error by mistake, please contact the webmaster.";
}       
//Road Name     
        if(email_existst($road_name)) {
            $errors [] = "Sorry, this Road Name is alreay taken. If you feel you have reach this error mistake, please contact the webmaster.";
}       

/// Insure Passwords are matching       
        if($password !== $confirm_password) {
            $errors [] = "Your password fields do not match";
}

//Error diplay          

        if(!empty($errors)) {

            foreach ($errors as $error) {

            echo validation_errors($error); 

            }

        } 

    else {  ////// Not Working Looking into.....

            if(register_user($first_name, $last_name, $road_name, $email, $member_id, $member_type, $phone_number, $password)){

                echo 'user registered';

            }

        }




    } // Post request

} // Function

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function register_user($first_name, $last_name, $road_name, $email, $member_id, $member_type, $phone_number, $password) {

    $first_name         = escape($first_name);          
    $last_name          = escape($last_name);
    $road_name          = escape($road_name);
    $email              = escape($email);
    $member_id          = escape($member_id);
    $member_type        = escape($member_type);
    $phone_number       = escape($phone_number);
    $password           = escape($password);


    if(email_existst($email)) {

        return false;

    } else if (road_name_existst($road_name)) {

        return false;


    } else {

    $password = md5($password); ///Will make better later

    $validation_code =  md5( rand() + rand() ); ///Will make better later

    $sql = "INSERT INTO users(first_name, last_name, road_name, email, member_id, member_type, phone_number, password, validation_code, active)";
    $sql.= " VALUES('$first_name', '$last_name', '$road_name', '$email', '$member_id', '$member_type', '$password', '$validation_code', '0')";

    $result = qurey($sql); ////WHY THE FUCK DO YOU NOT FUCKING WORK!!!!!!!!!!!!!!!!!!!!!!!!!!

    confirm($result);

    return true;    

    }

}///End register_user

////// End Validation Functions /////




?>

最后是php MyAdmin中的内容,我认为这也很好.....

-- phpMyAdmin SQL Dump
-- version 5.0.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 22, 2020 at 10:15 PM
-- Server version: 10.4.11-MariaDB
-- PHP Version: 7.4.2

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `login_db`
--

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(255) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `road_name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `member_id` varchar(255) NOT NULL,
  `member_type` varchar(255) NOT NULL,
  `phone_number` varchar(255) NOT NULL,
  `password` text NOT NULL,
  `validation_code` text NOT NULL,
  `active` tinyint(4) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `first_name`, `last_name`, `road_name`, `email`, `member_id`, `member_type`, `phone_number`, `password`, `validation_code`, `active`) VALUES
(1, 'Thomas', 'Hunter', 'Webmaster', '[email protected]', 'FM-1235', 'Full Member', '', '1234password', '', 0);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(255) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

哦,如果有帮助,这是梦中的编织者错误

<?xml version="1.0" standalone="yes" ?>

<mm_report>
    <mm_reportname> ResultsReport.xml</mm_reportname>
    <mm_reportdate>Sun Mar 22 17:21:19 2020</mm_reportdate>
    <mm_reportlocation>C:\\Users\thunter\Desktop\</mm_reportlocation>
    <mm_reportitem>
        <mm_statusicon>8</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber></mm_linenumber>
        <mm_description><![CDATA[ [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>9</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>49</mm_linenumber>
        <mm_description><![CDATA[This document appears to be written in English. Consider adding lang="en" (or variant) to the html start tag.  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>1</mm_linenumber>
        <mm_description><![CDATA[Saw <? . Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>49</mm_linenumber>
        <mm_description><![CDATA[Start tag seen without seeing a doctype first. Expected <!DOCTYPE html> .  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>49</mm_linenumber>
        <mm_description><![CDATA[Element head is missing a required instance of child element title .  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>51</mm_linenumber>
        <mm_description><![CDATA[Stray end tag div .  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>110</mm_linenumber>
        <mm_description><![CDATA[Bad character   after < . Probable cause: Unescaped < . Try escaping it as &lt; .  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>117</mm_linenumber>
        <mm_description><![CDATA[Bad character   after < . Probable cause: Unescaped < . Try escaping it as &lt; .  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>124</mm_linenumber>
        <mm_description><![CDATA[Bad character   after < . Probable cause: Unescaped < . Try escaping it as &lt; .  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
    <mm_reportitem>
        <mm_statusicon>10</mm_statusicon>
        <mm_displaystr><![CDATA[functions\functions.php]]></mm_displaystr>
        <mm_file>C:\xampp\htdocs\login\functions\functions.php</mm_file>
        <mm_linenumber>133</mm_linenumber>
        <mm_description><![CDATA[Bad character   after < . Probable cause: Unescaped < . Try escaping it as &lt; .  [html5]]]></mm_description>
        <mm_reportedby></mm_reportedby>
    </mm_reportitem>
</mm_report>

如果您已经走到了这一步,谢谢!谢谢!谢谢!谢谢!

php mysql mysqli phpmyadmin dreamweaver
1个回答
0
投票

query错误看起来很奇怪,但是很简单,您键入了错误的qurey并插入了[[query。]]第93行的错误与第48行的

HEREDOC

有关,为should not contain any whitespace after the closing delimiter

© www.soinside.com 2019 - 2024. All rights reserved.