I keep getting a fatal error from my browser when trying to create a user [on hold]
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
$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
New contributor
put on hold as off-topic by simonthesorcerer, Jai, Dhiren Vasoya, Piyush, Mohit Kumar Arora 2 days ago
- This question does not appear to be about the Magento e-Commerce platform within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
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
$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
New contributor
put on hold as off-topic by simonthesorcerer, Jai, Dhiren Vasoya, Piyush, Mohit Kumar Arora 2 days ago
- This question does not appear to be about the Magento e-Commerce platform within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.
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
Jan 14 at 21:06
4
I'm voting to close this question as off-topic because this is not a question related to Magento
– simonthesorcerer
Jan 14 at 21:38
add a comment |
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
$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
New contributor
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
$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
fatal-error
New contributor
New contributor
edited Jan 15 at 1:07
andyjv
1,96711740
1,96711740
New contributor
asked Jan 14 at 20:53
DanielDaniel
1
1
New contributor
New contributor
put on hold as off-topic by simonthesorcerer, Jai, Dhiren Vasoya, Piyush, Mohit Kumar Arora 2 days ago
- This question does not appear to be about the Magento e-Commerce platform within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by simonthesorcerer, Jai, Dhiren Vasoya, Piyush, Mohit Kumar Arora 2 days ago
- This question does not appear to be about the Magento e-Commerce platform within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.
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
Jan 14 at 21:06
4
I'm voting to close this question as off-topic because this is not a question related to Magento
– simonthesorcerer
Jan 14 at 21:38
add a comment |
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
Jan 14 at 21:06
4
I'm voting to close this question as off-topic because this is not a question related to Magento
– simonthesorcerer
Jan 14 at 21:38
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
Jan 14 at 21:06
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
Jan 14 at 21:06
4
4
I'm voting to close this question as off-topic because this is not a question related to Magento
– simonthesorcerer
Jan 14 at 21:38
I'm voting to close this question as off-topic because this is not a question related to Magento
– simonthesorcerer
Jan 14 at 21:38
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
add a comment |
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.
add a comment |
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.
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.
answered Jan 14 at 21:29
andyjvandyjv
1,96711740
1,96711740
add a comment |
add a comment |
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
Jan 14 at 21:06
4
I'm voting to close this question as off-topic because this is not a question related to Magento
– simonthesorcerer
Jan 14 at 21:38