How to get useful error messages in mysql query in php? [duplicate]How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_resultI cant understand why none of the data is getting inserted into the databasei'm trying to insert values to the table in my db, but there is something goes wrong, insertion query does not workHow do I fix this nested if statement?PHP does not insert data into a tableFirst query works, but the second doesn't and I've tried everythingTrying to insert the data in database using angular js but failed to do soHow do I get data from hardware from nodemcu and save it to database in raspberry pi?Tested with values and it works, but when I put variables it won't wordHow do I update MySQL data with a PHP/HTML form?How can I prevent SQL injection in PHP?How can I get useful error messages in PHP?How do I get PHP errors to display?How do I get a YouTube video thumbnail from the YouTube API?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Get the full URL in PHPHow to fix “Headers already sent” error in PHPHow does PHP 'foreach' actually work?Reference - What does this error mean in PHP?
TCP connections hang during handshake
What is the origin of "Wonder begets wisdom?"
Is there an English word to describe when a sound "protrudes"?
Are there foods that astronauts are explicitly never allowed to eat?
Why is there an extra "t" in Lemmatization?
Does the Bracer of Flying Daggers really let a thief make 4 attacks per round?
How to hook up Korg EX-8000 to a computer w/o a keyboard?
Nilpotent elements of Lie algebra and unipotent groups
Found old paper shares of Motorola Inc that has since been broken up
Date input format problem
Alignment problem with a mathematical equation in a presentation in beamer
What is the minimum wait before I may I re-enter the USA after a 90 day visit on the Visa B-2 Program?
Infinite points on circle
How far off did Apollo 11 land?
What is the intuition for higher homotopy groups not vanishing?
Book in which the "mountain" in the distance was a hole in the flat world
A Real World Example for Divide and Conquer Method
Can a creature sustain itself by eating its own severed body parts?
Host telling me to cancel my booking in exchange for a discount?
Project Euler # 25 The 1000 digit Fibonacci index
Discretisation of region intersection in 3D
Why is the forgetful functor representable?
Manager is asking me to eat breakfast from now on
Redirection operator, standard input and command parameters
How to get useful error messages in mysql query in php? [duplicate]
How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_resultI cant understand why none of the data is getting inserted into the databasei'm trying to insert values to the table in my db, but there is something goes wrong, insertion query does not workHow do I fix this nested if statement?PHP does not insert data into a tableFirst query works, but the second doesn't and I've tried everythingTrying to insert the data in database using angular js but failed to do soHow do I get data from hardware from nodemcu and save it to database in raspberry pi?Tested with values and it works, but when I put variables it won't wordHow do I update MySQL data with a PHP/HTML form?How can I prevent SQL injection in PHP?How can I get useful error messages in PHP?How do I get PHP errors to display?How do I get a YouTube video thumbnail from the YouTube API?How to get the client IP address in PHPHow do you parse and process HTML/XML in PHP?Get the full URL in PHPHow to fix “Headers already sent” error in PHPHow does PHP 'foreach' actually work?Reference - What does this error mean in PHP?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
This question already has an answer here:
How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result
1 answer
HTML code
<form class="col s6 " method="post" enctype="multipart/form-data">
<div class="input-field col s12">
<input id="last_name" type="text" name="name" class="validate">
<label for="last_name">Certificate Name</label>
</div>
<button type="submit" id="btnSubmit" name="btnSubmit" class="btn btn-default" style="margin-top:20px;">ADD</button>
</form>
PHP code
<?php
include('footer.php');
include('conn.php');
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO `isodetail`(`title`) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully')</script>";
echo "<script>window.open('isocerti.php','_self')</script>";
else
echo "<script>alert('Something Error!..please try Again..')</script>";
?>
This shows an alert message saying Something Error!..please try Again..
so is it mysqli_query
that has a mistake?
php
marked as duplicate by Your Common Sense
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Apr 6 at 15:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result
1 answer
HTML code
<form class="col s6 " method="post" enctype="multipart/form-data">
<div class="input-field col s12">
<input id="last_name" type="text" name="name" class="validate">
<label for="last_name">Certificate Name</label>
</div>
<button type="submit" id="btnSubmit" name="btnSubmit" class="btn btn-default" style="margin-top:20px;">ADD</button>
</form>
PHP code
<?php
include('footer.php');
include('conn.php');
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO `isodetail`(`title`) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully')</script>";
echo "<script>window.open('isocerti.php','_self')</script>";
else
echo "<script>alert('Something Error!..please try Again..')</script>";
?>
This shows an alert message saying Something Error!..please try Again..
so is it mysqli_query
that has a mistake?
php
marked as duplicate by Your Common Sense
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Apr 6 at 15:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Use themysqli_error
function: php.net/manual/en/mysqli.error.php Example:echo mysqli_error($conn);
– Steven
Jan 16 '18 at 6:36
it doesnt show any errors
– Archi Patel
Jan 16 '18 at 6:50
@Sandra read about variable parsing in strings. That code is correct as it is now.
– axiac
Jan 16 '18 at 7:05
Related: how-to-get-mysqli-error-information-in-different-environments
– Paul Spiegel
Apr 2 at 17:17
add a comment |
This question already has an answer here:
How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result
1 answer
HTML code
<form class="col s6 " method="post" enctype="multipart/form-data">
<div class="input-field col s12">
<input id="last_name" type="text" name="name" class="validate">
<label for="last_name">Certificate Name</label>
</div>
<button type="submit" id="btnSubmit" name="btnSubmit" class="btn btn-default" style="margin-top:20px;">ADD</button>
</form>
PHP code
<?php
include('footer.php');
include('conn.php');
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO `isodetail`(`title`) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully')</script>";
echo "<script>window.open('isocerti.php','_self')</script>";
else
echo "<script>alert('Something Error!..please try Again..')</script>";
?>
This shows an alert message saying Something Error!..please try Again..
so is it mysqli_query
that has a mistake?
php
This question already has an answer here:
How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result
1 answer
HTML code
<form class="col s6 " method="post" enctype="multipart/form-data">
<div class="input-field col s12">
<input id="last_name" type="text" name="name" class="validate">
<label for="last_name">Certificate Name</label>
</div>
<button type="submit" id="btnSubmit" name="btnSubmit" class="btn btn-default" style="margin-top:20px;">ADD</button>
</form>
PHP code
<?php
include('footer.php');
include('conn.php');
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO `isodetail`(`title`) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully')</script>";
echo "<script>window.open('isocerti.php','_self')</script>";
else
echo "<script>alert('Something Error!..please try Again..')</script>";
?>
This shows an alert message saying Something Error!..please try Again..
so is it mysqli_query
that has a mistake?
This question already has an answer here:
How to get MySQLi error information in different environments? / mysqli_fetch_assoc() expects parameter 1 to be mysqli_result
1 answer
php
php
edited Jan 16 '18 at 6:54
Jeff
10.3k5 gold badges26 silver badges51 bronze badges
10.3k5 gold badges26 silver badges51 bronze badges
asked Jan 16 '18 at 6:25
Archi PatelArchi Patel
3711 bronze badges
3711 bronze badges
marked as duplicate by Your Common Sense
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Apr 6 at 15:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Your Common Sense
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Apr 6 at 15:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
Use themysqli_error
function: php.net/manual/en/mysqli.error.php Example:echo mysqli_error($conn);
– Steven
Jan 16 '18 at 6:36
it doesnt show any errors
– Archi Patel
Jan 16 '18 at 6:50
@Sandra read about variable parsing in strings. That code is correct as it is now.
– axiac
Jan 16 '18 at 7:05
Related: how-to-get-mysqli-error-information-in-different-environments
– Paul Spiegel
Apr 2 at 17:17
add a comment |
Use themysqli_error
function: php.net/manual/en/mysqli.error.php Example:echo mysqli_error($conn);
– Steven
Jan 16 '18 at 6:36
it doesnt show any errors
– Archi Patel
Jan 16 '18 at 6:50
@Sandra read about variable parsing in strings. That code is correct as it is now.
– axiac
Jan 16 '18 at 7:05
Related: how-to-get-mysqli-error-information-in-different-environments
– Paul Spiegel
Apr 2 at 17:17
Use the
mysqli_error
function: php.net/manual/en/mysqli.error.php Example: echo mysqli_error($conn);
– Steven
Jan 16 '18 at 6:36
Use the
mysqli_error
function: php.net/manual/en/mysqli.error.php Example: echo mysqli_error($conn);
– Steven
Jan 16 '18 at 6:36
it doesnt show any errors
– Archi Patel
Jan 16 '18 at 6:50
it doesnt show any errors
– Archi Patel
Jan 16 '18 at 6:50
@Sandra read about variable parsing in strings. That code is correct as it is now.
– axiac
Jan 16 '18 at 7:05
@Sandra read about variable parsing in strings. That code is correct as it is now.
– axiac
Jan 16 '18 at 7:05
Related: how-to-get-mysqli-error-information-in-different-environments
– Paul Spiegel
Apr 2 at 17:17
Related: how-to-get-mysqli-error-information-in-different-environments
– Paul Spiegel
Apr 2 at 17:17
add a comment |
1 Answer
1
active
oldest
votes
In the else-block you can see, how you can catch up MySQL-errors and display them in an alert.
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO isodetail(title) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully');window.open('isocerti.php','_self');</script>";
else
$error = addslashes(mysqli_error($conn));
echo "<script>alert('An Error occur: $error');</script>";
References:
MySQLi-Error: http://php.net/manual/en/mysqli.error.php
Escape special characters: http://php.net/manual/en/function.addslashes.php (it does the job for this example)
@ArchiPatel So you have your correct error, now you can start debug it. My first idea will be:INSERT isodetail(title, name) VALUES ('$name', '')
but that's just a guess without knowledge about your database structure.
– Steven
Jan 16 '18 at 7:29
yes i got this ...Thank you so much.
– Archi Patel
Jan 16 '18 at 7:36
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In the else-block you can see, how you can catch up MySQL-errors and display them in an alert.
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO isodetail(title) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully');window.open('isocerti.php','_self');</script>";
else
$error = addslashes(mysqli_error($conn));
echo "<script>alert('An Error occur: $error');</script>";
References:
MySQLi-Error: http://php.net/manual/en/mysqli.error.php
Escape special characters: http://php.net/manual/en/function.addslashes.php (it does the job for this example)
@ArchiPatel So you have your correct error, now you can start debug it. My first idea will be:INSERT isodetail(title, name) VALUES ('$name', '')
but that's just a guess without knowledge about your database structure.
– Steven
Jan 16 '18 at 7:29
yes i got this ...Thank you so much.
– Archi Patel
Jan 16 '18 at 7:36
add a comment |
In the else-block you can see, how you can catch up MySQL-errors and display them in an alert.
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO isodetail(title) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully');window.open('isocerti.php','_self');</script>";
else
$error = addslashes(mysqli_error($conn));
echo "<script>alert('An Error occur: $error');</script>";
References:
MySQLi-Error: http://php.net/manual/en/mysqli.error.php
Escape special characters: http://php.net/manual/en/function.addslashes.php (it does the job for this example)
@ArchiPatel So you have your correct error, now you can start debug it. My first idea will be:INSERT isodetail(title, name) VALUES ('$name', '')
but that's just a guess without knowledge about your database structure.
– Steven
Jan 16 '18 at 7:29
yes i got this ...Thank you so much.
– Archi Patel
Jan 16 '18 at 7:36
add a comment |
In the else-block you can see, how you can catch up MySQL-errors and display them in an alert.
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO isodetail(title) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully');window.open('isocerti.php','_self');</script>";
else
$error = addslashes(mysqli_error($conn));
echo "<script>alert('An Error occur: $error');</script>";
References:
MySQLi-Error: http://php.net/manual/en/mysqli.error.php
Escape special characters: http://php.net/manual/en/function.addslashes.php (it does the job for this example)
In the else-block you can see, how you can catch up MySQL-errors and display them in an alert.
if(isset($_POST['btnSubmit']))
$name = mysqli_real_escape_string($conn,$_POST["name"]);
$sql = "INSERT INTO isodetail(title) VALUES ('$name')";
$run = mysqli_query($conn, $sql);
if($run)
echo "<script>alert('Certi Added Successfully');window.open('isocerti.php','_self');</script>";
else
$error = addslashes(mysqli_error($conn));
echo "<script>alert('An Error occur: $error');</script>";
References:
MySQLi-Error: http://php.net/manual/en/mysqli.error.php
Escape special characters: http://php.net/manual/en/function.addslashes.php (it does the job for this example)
answered Jan 16 '18 at 7:01
StevenSteven
3792 silver badges10 bronze badges
3792 silver badges10 bronze badges
@ArchiPatel So you have your correct error, now you can start debug it. My first idea will be:INSERT isodetail(title, name) VALUES ('$name', '')
but that's just a guess without knowledge about your database structure.
– Steven
Jan 16 '18 at 7:29
yes i got this ...Thank you so much.
– Archi Patel
Jan 16 '18 at 7:36
add a comment |
@ArchiPatel So you have your correct error, now you can start debug it. My first idea will be:INSERT isodetail(title, name) VALUES ('$name', '')
but that's just a guess without knowledge about your database structure.
– Steven
Jan 16 '18 at 7:29
yes i got this ...Thank you so much.
– Archi Patel
Jan 16 '18 at 7:36
@ArchiPatel So you have your correct error, now you can start debug it. My first idea will be:
INSERT isodetail(title, name) VALUES ('$name', '')
but that's just a guess without knowledge about your database structure.– Steven
Jan 16 '18 at 7:29
@ArchiPatel So you have your correct error, now you can start debug it. My first idea will be:
INSERT isodetail(title, name) VALUES ('$name', '')
but that's just a guess without knowledge about your database structure.– Steven
Jan 16 '18 at 7:29
yes i got this ...Thank you so much.
– Archi Patel
Jan 16 '18 at 7:36
yes i got this ...Thank you so much.
– Archi Patel
Jan 16 '18 at 7:36
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Use the
mysqli_error
function: php.net/manual/en/mysqli.error.php Example:echo mysqli_error($conn);
– Steven
Jan 16 '18 at 6:36
it doesnt show any errors
– Archi Patel
Jan 16 '18 at 6:50
@Sandra read about variable parsing in strings. That code is correct as it is now.
– axiac
Jan 16 '18 at 7:05
Related: how-to-get-mysqli-error-information-in-different-environments
– Paul Spiegel
Apr 2 at 17:17