How to get useful error messages in mysql query in php? The Next CEO of Stack OverflowI cant understand why none of the data is getting inserted into the databasePHP / MySQL: Cannot retrieve any data from databasePHP does not insert data into a tableHow can I prevent SQL injection in PHP?How to 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?
How do I fit a non linear curve?
how one can write a nice vector parser, something that does pgfvecparseA=B-C; D=E x F;
Man transported from Alternate World into ours by a Neutrino Detector
Why do we say 'Un seul M' and not 'Une seule M' even though M is a "consonne"
Is it professional to write unrelated content in an almost-empty email?
The Ultimate Number Sequence Puzzle
How to use ReplaceAll on an expression that contains a rule
Is it convenient to ask the journal's editor for two additional days to complete a review?
TikZ: How to fill area with a special pattern?
Reshaping json / reparing json inside shell script (remove trailing comma)
Towers in the ocean; How deep can they be built?
What is the process for purifying your home if you believe it may have been previously used for pagan worship?
Where do students learn to solve polynomial equations these days?
From jafe to El-Guest
Can this note be analyzed as a non-chord tone?
Ising model simulation
How do you define an element with an ID attribute using LWC?
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
Does the Idaho Potato Commission associate potato skins with healthy eating?
What difference does it make using sed with/without whitespaces?
Aggressive Under-Indexing and no data for missing index
Can you teleport closer to a creature you are Frightened of?
Do scriptures give a method to recognize a truly self-realized person/jivanmukta?
Could a dragon use its wings to swim?
How to get useful error messages in mysql query in php?
The Next CEO of Stack OverflowI cant understand why none of the data is getting inserted into the databasePHP / MySQL: Cannot retrieve any data from databasePHP does not insert data into a tableHow can I prevent SQL injection in PHP?How to 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?
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
add a comment |
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
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
add a comment |
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
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
php
edited Jan 16 '18 at 6:54
Jeff
9,68952450
9,68952450
asked Jan 16 '18 at 6:25
Archi PatelArchi Patel
4111
4111
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
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
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
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 |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48275205%2fhow-to-get-useful-error-messages-in-mysql-query-in-php%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
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
383210
383210
@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 |
Thanks for contributing an answer to Stack Overflow!
- 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48275205%2fhow-to-get-useful-error-messages-in-mysql-query-in-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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