I'm using php 5.2.13 and Oracle database.
And I'm trying to hide error messages, but doesn't work.
I tried to...
add this code to the page where an error occurs
ini_set(display_errors,0);
set an option in php.ini
display_errors = Off
...and what else should I do?? I thought I had done enough.
And the error message is coming from Oracle like this;
ORA-01400 cannot insert NULL into .....
I wonder if there's any modules in php that display error messages..?
thanks.
This is not a PHP error, but a Oracle error, your column can't be null - you need to specify a value. That's why your display_error's doesn't hide this error.
I have to emphasize - like others in the comments - that the only good error is a fixed one.
How about using LOG ERRORS INTO on your DML, this should allow you to dump your errors to a table for later inspection.
see: http://www.oracle-developer.net/display.php?id=329
and: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#BGBDIGAH
Related
I am using a php mysql based crm software which is made using Codeigniter.
I don't have any knowledge about Codeigniter.
I just customized it as per my requirements.
Whenever I am trying to save any data I am getting this error.
While using in Xampp I did not get these errors.
When I put it online I started to get these. Also I tried to ignore PHP errors, warnings using
error_reporting(0);
in my controller/admin.php
This would just hide the errors and not ignore them and proceed to the redirected page after the save.
If anything else is needed please let me know.
Undefined index -- that's the error you need to resolve here. You're most likely trying to access a property of $_GET or $_POST using an incorrect key name.
For the sake of debugging, try this:
if(isset($_GET['keyname'])) {
$myObj->prop = $_GET['keyname'];
} else {
show_error('No value set for keyname', 500);
}
I'm making a lot of assumptions about your code here, replace keyname with whatever you are trying to access.
For reference, you should probably switch to using the CodeIgniter Input Class to get values from GET/POST.
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
PHP call class in class returns error:500
I have code that looks somewhat like this:
<?php
include 'payTable.php';
session_start();
...
if ($_SESSION['fieldTen'] > 30)
{
$payTable = 'payTable';
$payTable::run();
}
?>
My permissions are set to 0644, so I don't think that's the issue, but I'm getting strange behavior on the server that I'm not getting in the local directory using XAMP.
Every time I try to load the page with this code on it, I get the "Internal Server Error: 500" error.
Can anyone tell me if there's something obviously wrong here? Something I'm missing.
I tried simply removing the PHP from this file and that causes the HTML part of it to appear without problems.
This is not legal syntax on PHP < 5.3.0, so you're getting a syntax error:
$payTable = 'payTable';
$payTable::run();
PHP (< 5.3.0) thinks $payTable is a string, so you can't use ::run() on it.
The solution would be just to ditch the variable altogether and call it directly:
payTable::run();
On a related note, turn on your error reporting. This will allow you to spot and fix errors easily rather than being left in the dark with a generic error. You can do this by editing php.ini (preferred), or add this to the top of your scripts:
error_reporting(E_ALL);
ini_set("display_errors","On");
It looks like you are trying to call a function of 'payTable', but payTable is not a class with any functions.
Additionally, you could be trying to set the session after some data has been output... possibly from the included file? this will throw an error, but likely not as severe as a 500.
500 just means the server hit a problem and couldn't continue. You need to check the error log for the web server (presumably apache?) to see what the actual problem was. Looking at the code, off the cuff guess could be the case of the included filename doesn't match the actual filename.
So - strange situation I got here.
The statement error_reporting(0); has been giving me a server 500 error.
However, error_reporting(1); works just fine..
And its killing me, too many warnings for some of my URL validators. What's up with this? Any idea on how this can be fixed?
First of all, I'm sorry if I behave "smartass", but I have to tell you that if there are warnings, you should consider to fix them instead of just reduce them to silence... :)
Junk PHP code let bad things happen, and you won't like it. I understand 80% of the PHP code around is junk, but really try to fix that library, if it's not huge.
We can however try to solve the problem if you just make a simple .php file, with only one line:
<?php
error_reporting(0);
?>
and test if it fires the error. If it doesn't, the problem is not caused by error_reporting, but just triggered by it, and there's some sick stuff going on elsewhere. :)
try error_reporting(E_ALL); and ini_set("display_errors","On"); and check the errors that occur. After you fix those, there shouldn't be any problem.
Good luck
Shai.
P.S. i would be guessing for almost 100% that you use Chrome, because for some reason chrome would sometimes just show its own error screen instead of showing error messages. So also try another browser just to check the errors.
error_reporting()'s value is defined with constants, so don't use direct value to set it.
If you had used the constants, you would have noticed that none of them have 0 as value.
If you want to report all errors, there is an exception to the rule : use the value -1 :
error_reporting(-1);
Source : http://us.php.net/manual/en/function.error-reporting.php
And consider fixing all warnings! (and even notices if possible)
Note : the -1 value is used to be sure that even if more error code are added, they are all included.
I installed phpMyAdmin on my site and it works. But when I mistype a query it does not show the mysql error message only the error code.
1064 -
I expect the following:
1064 - You have and error in your blah blah...
Without an error message it's difficult to know what's wrong.
In my php scripts I'm able to get the error message via mysql_error(). But myAdmin shows nothing.
I googled a lot but I didn't find anything useful.
How can I make it show the error messages?
Any ideas?
Judging by the fact that you get "#1064 -" as output, I can find only two places in the phpMyAdmin 3.3.9.2 source where the error could be occurring. The first is in the call to mysql_error or mysqli_error, depending on which backend your installation is using. I see you said that mysql_error works fine; if the phpMyAdmin information page you get when first logging in indicates that mysqli is being used, you might want to check that too.
But if mysql_error works, it seems more likely that the problem is in phpMyAdmin's character set conversion function PMA_DBI_convert_message in libraries/database_interface.lib.php. You can confirm this easily enough by inserting return $message; at the very top of that function, bypassing everything else in there. If that makes it (more or less) work, you'd probably want to determine what $server_language and $GLOBALS['charset'] are getting set to; see if the conversion is using iconv, recode_string, libiconv, or mb_convert_encoding; and then try to work out why whichever of those is failing to convert the error message properly.
Probably, Server cannot correctly access LOCALE settings. It happens on chroot-ed / chjail-ed environments or poor configuration.
Based on #Anomie answer, I made a workaround.
For phpmyadmin 4.4.3 change the Fallback setting in file libraries/DatabaseInterface.class.php
/* Fallback to CP1252 if we can not detect */
$encoding = 'UTF-8';
For some older versions, edit file libraries/database_interface.lib.php and set
array $encodings => 'english' value to UTF-8 (~line 273),
'english' => 'UTF-8', //'latin1',
Did you see :
$cfg['Error_Handler']['display']
boolean
Whether to display errors from PHP or not.
$cfg['Error_Handler']['gather']
boolean
Whether to gather errors from PHP or not.
In the docs ?
Had the same problem, which was solved by disabling the FireFox add-on uBlock (version: Origin 1.25.2) in my browser for phpmyadmin.
I was wondering how can I stop PHP & MySQL errors from displaying to users but still have the errors logged in the server so I know something is wrong.
two ways:
Config your php.ini (turn error off)
Put a # after any action...
Example:
<?php
$a = #mysq_query("a bad query");
echo #$b; // $b donst exist, so thrwos an error but with the # dosnt show anything
?>
I want to point out that there is a good reason to surpress MySQL Errors. If there error gives away too much info about your database set up and schema (by showing the query in the error... joins... etc.) you don't want a live site showing those errors to the public. Of course you would want to log them. So in the interest of security this is a good single reason to not display them on a live site. As I said logging yes. Displaying no.
http://www.php.net/manual/en/errorfunc.configuration.php
Set display_errors to zero and define a log file with error_log in your php.ini or with ini_set or something.