I keep getting a fatal error from my browser when trying to create a user












0















Please help! I keep getting the below error message from my browser from the code below it. Any help would be appreciated.



Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:xampp2htdocsinsert.php:28 Stack trace: #0 {main} thrown in C:xampp2htdocsinsert.php on line 28



<?php
$user_name = $_POST['user_name'];
$user_password = $_POST['user_password'];
$phone_number = $_POST['phone_number'];
$user_email = $_POST['user_email'];
if (!empty($user_name) || !empty($user_password) || !empty($phone_number) || !empty($user_email)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "loginsystem";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT user_email From users Where user_email = ? Limit 1";
$INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $user_email);
$stmt->execute();
$stmt->bind_result($user_email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
*$stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);*
$stmt->execute();
echo "New record inserted sucessfully";
} else {
echo "Someone already registered using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>








share







New contributor




Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Hi, welcome to the Magento Stack Exchange! Make sure you read up on How to Ask , and then edit your question to improve formatting and add any additional details that might help (Magento version, what you're really trying to do, what you've tried, etc)

    – andyjv
    3 hours ago











  • I'm voting to close this question as off-topic because this is not a question related to Magento

    – simonthesorcerer
    2 hours ago
















0















Please help! I keep getting the below error message from my browser from the code below it. Any help would be appreciated.



Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:xampp2htdocsinsert.php:28 Stack trace: #0 {main} thrown in C:xampp2htdocsinsert.php on line 28



<?php
$user_name = $_POST['user_name'];
$user_password = $_POST['user_password'];
$phone_number = $_POST['phone_number'];
$user_email = $_POST['user_email'];
if (!empty($user_name) || !empty($user_password) || !empty($phone_number) || !empty($user_email)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "loginsystem";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT user_email From users Where user_email = ? Limit 1";
$INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $user_email);
$stmt->execute();
$stmt->bind_result($user_email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
*$stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);*
$stmt->execute();
echo "New record inserted sucessfully";
} else {
echo "Someone already registered using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>








share







New contributor




Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Hi, welcome to the Magento Stack Exchange! Make sure you read up on How to Ask , and then edit your question to improve formatting and add any additional details that might help (Magento version, what you're really trying to do, what you've tried, etc)

    – andyjv
    3 hours ago











  • I'm voting to close this question as off-topic because this is not a question related to Magento

    – simonthesorcerer
    2 hours ago














0












0








0








Please help! I keep getting the below error message from my browser from the code below it. Any help would be appreciated.



Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:xampp2htdocsinsert.php:28 Stack trace: #0 {main} thrown in C:xampp2htdocsinsert.php on line 28



<?php
$user_name = $_POST['user_name'];
$user_password = $_POST['user_password'];
$phone_number = $_POST['phone_number'];
$user_email = $_POST['user_email'];
if (!empty($user_name) || !empty($user_password) || !empty($phone_number) || !empty($user_email)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "loginsystem";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT user_email From users Where user_email = ? Limit 1";
$INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $user_email);
$stmt->execute();
$stmt->bind_result($user_email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
*$stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);*
$stmt->execute();
echo "New record inserted sucessfully";
} else {
echo "Someone already registered using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>








share







New contributor




Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












Please help! I keep getting the below error message from my browser from the code below it. Any help would be appreciated.



Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:xampp2htdocsinsert.php:28 Stack trace: #0 {main} thrown in C:xampp2htdocsinsert.php on line 28



<?php
$user_name = $_POST['user_name'];
$user_password = $_POST['user_password'];
$phone_number = $_POST['phone_number'];
$user_email = $_POST['user_email'];
if (!empty($user_name) || !empty($user_password) || !empty($phone_number) || !empty($user_email)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "loginsystem";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT user_email From users Where user_email = ? Limit 1";
$INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $user_email);
$stmt->execute();
$stmt->bind_result($user_email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
*$stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);*
$stmt->execute();
echo "New record inserted sucessfully";
} else {
echo "Someone already registered using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>






fatal-error





share







New contributor




Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share







New contributor




Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share



share






New contributor




Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









DanielDaniel

1




1




New contributor




Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Daniel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Hi, welcome to the Magento Stack Exchange! Make sure you read up on How to Ask , and then edit your question to improve formatting and add any additional details that might help (Magento version, what you're really trying to do, what you've tried, etc)

    – andyjv
    3 hours ago











  • I'm voting to close this question as off-topic because this is not a question related to Magento

    – simonthesorcerer
    2 hours ago



















  • Hi, welcome to the Magento Stack Exchange! Make sure you read up on How to Ask , and then edit your question to improve formatting and add any additional details that might help (Magento version, what you're really trying to do, what you've tried, etc)

    – andyjv
    3 hours ago











  • I'm voting to close this question as off-topic because this is not a question related to Magento

    – simonthesorcerer
    2 hours ago

















Hi, welcome to the Magento Stack Exchange! Make sure you read up on How to Ask , and then edit your question to improve formatting and add any additional details that might help (Magento version, what you're really trying to do, what you've tried, etc)

– andyjv
3 hours ago





Hi, welcome to the Magento Stack Exchange! Make sure you read up on How to Ask , and then edit your question to improve formatting and add any additional details that might help (Magento version, what you're really trying to do, what you've tried, etc)

– andyjv
3 hours ago













I'm voting to close this question as off-topic because this is not a question related to Magento

– simonthesorcerer
2 hours ago





I'm voting to close this question as off-topic because this is not a question related to Magento

– simonthesorcerer
2 hours ago










1 Answer
1






active

oldest

votes


















0














First, we need to look at the error message. Specifically, your error is this:




Call to a member function bind_param() on bool




Your error message also gives us a line number (and it looks like your pasted code includes asterisks around that line). So lets look at the line where the error occurred:



$stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);



Your error message is saying that you've called bind_param on a bool (boolean), which means your variable $stmt is not the mysqli object you're expecting. Next we look at the line before to find out why $stmt is a boolean. On that line you called the function prepare(). If we look at the PHP documenation for that function, we can see that it will return FALSE if there was an error.



So now we know there was an error when preparing your insert statement. If we go up and look at your insert statement
$INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
you'll notice an extra comma after user_email. Delete the comma, and your code should work.



Most coding environments should pick up and flag that type of error for you, so that you don't have to go through a long debugging process. There are a number of free ones out there, and I strongly recommend looking into using one of them.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Daniel is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257752%2fi-keep-getting-a-fatal-error-from-my-browser-when-trying-to-create-a-user%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    First, we need to look at the error message. Specifically, your error is this:




    Call to a member function bind_param() on bool




    Your error message also gives us a line number (and it looks like your pasted code includes asterisks around that line). So lets look at the line where the error occurred:



    $stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);



    Your error message is saying that you've called bind_param on a bool (boolean), which means your variable $stmt is not the mysqli object you're expecting. Next we look at the line before to find out why $stmt is a boolean. On that line you called the function prepare(). If we look at the PHP documenation for that function, we can see that it will return FALSE if there was an error.



    So now we know there was an error when preparing your insert statement. If we go up and look at your insert statement
    $INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
    you'll notice an extra comma after user_email. Delete the comma, and your code should work.



    Most coding environments should pick up and flag that type of error for you, so that you don't have to go through a long debugging process. There are a number of free ones out there, and I strongly recommend looking into using one of them.






    share|improve this answer




























      0














      First, we need to look at the error message. Specifically, your error is this:




      Call to a member function bind_param() on bool




      Your error message also gives us a line number (and it looks like your pasted code includes asterisks around that line). So lets look at the line where the error occurred:



      $stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);



      Your error message is saying that you've called bind_param on a bool (boolean), which means your variable $stmt is not the mysqli object you're expecting. Next we look at the line before to find out why $stmt is a boolean. On that line you called the function prepare(). If we look at the PHP documenation for that function, we can see that it will return FALSE if there was an error.



      So now we know there was an error when preparing your insert statement. If we go up and look at your insert statement
      $INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
      you'll notice an extra comma after user_email. Delete the comma, and your code should work.



      Most coding environments should pick up and flag that type of error for you, so that you don't have to go through a long debugging process. There are a number of free ones out there, and I strongly recommend looking into using one of them.






      share|improve this answer


























        0












        0








        0







        First, we need to look at the error message. Specifically, your error is this:




        Call to a member function bind_param() on bool




        Your error message also gives us a line number (and it looks like your pasted code includes asterisks around that line). So lets look at the line where the error occurred:



        $stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);



        Your error message is saying that you've called bind_param on a bool (boolean), which means your variable $stmt is not the mysqli object you're expecting. Next we look at the line before to find out why $stmt is a boolean. On that line you called the function prepare(). If we look at the PHP documenation for that function, we can see that it will return FALSE if there was an error.



        So now we know there was an error when preparing your insert statement. If we go up and look at your insert statement
        $INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
        you'll notice an extra comma after user_email. Delete the comma, and your code should work.



        Most coding environments should pick up and flag that type of error for you, so that you don't have to go through a long debugging process. There are a number of free ones out there, and I strongly recommend looking into using one of them.






        share|improve this answer













        First, we need to look at the error message. Specifically, your error is this:




        Call to a member function bind_param() on bool




        Your error message also gives us a line number (and it looks like your pasted code includes asterisks around that line). So lets look at the line where the error occurred:



        $stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);



        Your error message is saying that you've called bind_param on a bool (boolean), which means your variable $stmt is not the mysqli object you're expecting. Next we look at the line before to find out why $stmt is a boolean. On that line you called the function prepare(). If we look at the PHP documenation for that function, we can see that it will return FALSE if there was an error.



        So now we know there was an error when preparing your insert statement. If we go up and look at your insert statement
        $INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
        you'll notice an extra comma after user_email. Delete the comma, and your code should work.



        Most coding environments should pick up and flag that type of error for you, so that you don't have to go through a long debugging process. There are a number of free ones out there, and I strongly recommend looking into using one of them.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        andyjvandyjv

        1,96511740




        1,96511740






















            Daniel is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Daniel is a new contributor. Be nice, and check out our Code of Conduct.













            Daniel is a new contributor. Be nice, and check out our Code of Conduct.












            Daniel is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257752%2fi-keep-getting-a-fatal-error-from-my-browser-when-trying-to-create-a-user%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Polycentropodidae

            Magento 2 Error message: Invalid state change requested

            Paulmy