BR
asked on
if the error reporting is off, how can I understand if mysql update sentence works or not?
Dear Experts,
how can I understand if mysql update sentence works or not?
I use a shared server. My error reporting are turned off for security reasons I suppose.
my sql sentence is like this:
when it works, no problem, but when it doesn't work,
I see nothing, so I thought it worked although it didn't.
what do you suggest I shoulddo to understand if it is working or not ?
how can I understand if mysql update sentence works or not?
I use a shared server. My error reporting are turned off for security reasons I suppose.
my sql sentence is like this:
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql3 = "UPDATE myTable SET lat='$latitude', longt='$logtitude' WHERE user='$uid' ";
$result3 = $conn->query($sql3);
when it works, no problem, but when it doesn't work,
I see nothing, so I thought it worked although it didn't.
what do you suggest I shoulddo to understand if it is working or not ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dear Julian Hansen,
I learned a lot from you, thank you so much.
My Error file is enormous, I need to correct many things :)
thank you so much
I learned a lot from you, thank you so much.
My Error file is enormous, I need to correct many things :)
thank you so much
Here is how I would handle it.
1. Don't use die() -- instead get in the habit of using trigger_error() as shown in this article.
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
2. For development environments, use these settings:
http://php.net/manual/en/errorfunc.configuration.php <-- Worth reading all of this!
http://php.net/manual/en/function.error-log.php
http://php.net/manual/en/function.error-reporting.php
To find and display the error_log(s) in your project directories, you might use something like this. I have a modified version that runs once a minute (cron triggers it) and it sends me a message if an error_log file appears.
1. Don't use die() -- instead get in the habit of using trigger_error() as shown in this article.
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html
2. For development environments, use these settings:
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('log_errors', TRUE);
ini_set('error_log', 'error_log');
3. For deployed environments, use these settings:error_reporting(E_ALL);
ini_set('display_errors', FALSE);
ini_set('log_errors', TRUE);
ini_set('error_log', 'error_log');
You can check your settings by running this script, shown here in its entirety:<?php phpinfo();
Refs:http://php.net/manual/en/errorfunc.configuration.php <-- Worth reading all of this!
http://php.net/manual/en/function.error-log.php
http://php.net/manual/en/function.error-reporting.php
To find and display the error_log(s) in your project directories, you might use something like this. I have a modified version that runs once a minute (cron triggers it) and it sends me a message if an error_log file appears.
<?php // demo/find_error_log.php
/**
* Put this script in the web root directory
*
* Traverse all directories down the web tree
* Show and optionally delete the error log files
*
* http://php.net/manual/en/class.recursivedirectoryiterator.php#85805
*/
ob_start();
error_reporting( E_ALL );
ini_set( 'display_errors', TRUE );
ini_set( 'log_errors', TRUE );
// START IN THE CURRENT DIRECTORY
$path = realpath(getcwd());
$plen = strlen($path);
// THE ERROR LOG FILE NAME
$signal = strrev(ini_get('error_log'));
// IF THERE IS A POST-METHOD REQUEST TO DELETE THIS ERROR LOG
if (!empty($_POST['log']))
{
// MAKE SURE WE ONLY UNLINK THE ERROR LOG FILE
$test = strrev($_POST['log']);
if (strpos($test, $signal) === 0)
{
@unlink($path . $_POST['log']);
echo '<h3>' . $_POST['log'] . ' Discarded</h3>';
}
}
// COLLECT THE DIRECTORY INFORMATION OBJECTS
$objs = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
// ITERATE OVER THE OBJECTS
foreach($objs as $name => $obj)
{
// PROCESS THE ERROR LOG ONLY
$test = strrev($name);
if (strpos($test, $signal) === 0)
{
// CREATE A DELETE BUTTON FOR THIS ERROR LOG
$name = substr($name, $plen);
$form = <<<EOD
<form method="post" style="margin:0; padding:0; display:inline;!important">
<b>$name</b>
<input type="submit" value="Discard?" />
<input type="hidden" name="log" value="$name" />
</form>
EOD;
echo $form;
// SHOW THE CONTENTS OF THIS ERROR LOG
echo '<pre>';
print_r(file_get_contents($path . $name));
echo PHP_EOL . '********** EOF **********';
echo '</pre>' . PHP_EOL;
}
}
// IF THERE ARE NO ERROR LOG(S)
$out = ob_get_contents();
if (empty($out)) echo '<h3>Good News! No error_log found.</h3>';
// SHOW THE GIT BRANCH
$root = '.git/HEAD';
$text = @file_get_contents($root);
if ($text)
{
$text = explode(DIRECTORY_SEPARATOR, $text);
$text = array_slice($text, 2);
$name = implode(DIRECTORY_SEPARATOR, $text);
echo PHP_EOL . "On Git branch: $name" . PHP_EOL;
}
else
{
echo PHP_EOL . "On Git branch: UNKNOWN" . PHP_EOL;
}
echo '<a href="' . $_SERVER['REQUEST_URI'] . '">Run Again</a>?' . PHP_EOL;
// SCRIPT TERMINATION WILL FLUSH THE OUTPUT BUFFER TO THE CLIENT BROWSER
ASKER
Thank you Ray Paseur,
I will read it carefully. Thank you so much
I will read it carefully. Thank you so much
ASKER
Thank you Ray Paseur, that was a great answer,
I didn't know that error reporting is that much important.
Thank you so much.
I didn't know that error reporting is that much important.
Thank you so much.
@Braveheartli: I should have written this article a couple of years ago. But at least it's here now:
https://www.experts-exchange.com/articles/29115/PHP-Error-Handling-Never-die-Again.html
It may not be viewable yet (still in draft) but hopefully it will help answer questions like this one!
https://www.experts-exchange.com/articles/29115/PHP-Error-Handling-Never-die-Again.html
It may not be viewable yet (still in draft) but hopefully it will help answer questions like this one!
ASKER