I have this PHP script http://snippi.com/s/kx0k48g (too long for here, but put it in Snippi). It is built to run by an AJAX GET request. When I supply all the right GET parameters the script seems to run fine (no errors), but it won't echo or anthing else that the script does (inserting in the Database). It only shows something (errors) when I do not supply the right GET parameters. Any idea what could be wrong? It is extremely hard to debug, because it won't tell me that anything is wrong, but refuses to do the right thing.
Any help would be appreciated. Thanks!
Try using trigger_error() in PHP for debugging instead of echo. Then you don't have to worry about output buffering, etc.
trigger_error("I have reached checkpoint 1!", E_USER_WARNING);
Put a tail -f on your error log for your web server and see how far you get.
http://php.net/manual/en/function.trigger-error.php
Related
I have a simple ruby script which prints a exception message when something goes wrong.
i am unable to find where the logs are stored to check this.
any help on this would be really great.
Thanks.
There are no log files. When errors occur, the Ruby standard library will write its messages to the standard error stream. You can redirect this to a file if you'd like.
Of course, you can do whatever you want in your own code. It's absolutely possible to open a file and log messages to it. There are many logging libraries that provide this functionality.
I'm developing a Laravel 8.x app in the current version of VS Code. I have a dump() statement in a Controller that I've written so that I can determine precisely what's in the $request that is being handled because I suspect that my date isn't exactly what I think it is. I've added this to the store() method: $request->dump() and I'm pretty sure it has executed but I can't find the output from the dump() function anywhere. I've got Debugbar installed and it does not show the dump() output. Ditto for any window of the browser like the console, inspector, etc. I've looked in the laravel.log but it's not there either. I've checked each of my terminal windows - the ones dedicated to php artisan serve and npm run watch and the one I use for all other commands but I can't find anything there. I'm out of ideas on where to look.
If the Laravel docs tell you where to find the output, I missed it; they describe what dump() and dd() do but I can't find where they describe where the output is written.
I'm pretty new to Laravel and I'm working alone so I have no work colleagues to ask. Could someone kindly tell me where to find the output of dump() so that I can debug this program?
None of the comments pointed me to precisely where I eventually found the dd() output so I'm posting it here for the sake of any future person who has the same issue. I finally found it in the browser, in the console tab (I'm using Firefox) and within the Response to the Axios statement that tried to write the new record to the database. Here's a picture:
I had assumed that the information wouldn't require me to drill down as far as I did; I thought it would be as visible as normal console.log() output.
I'm very grateful to those who replied to my question; you finally got me looking in the exact right place. I've never used dd() or dump() before, even in vanilla PHP, so I really had no idea where the output got written.
Basically I am trying to start httpd.exe from command prompt. So if any error occurs i should be able to catch the reason in codes, why it wasn't able to start. I know it already gives the exact reason but I want to display my own errors.
Is there any error codes like 0, 1, etc for httpd.exe.
The Apache Http Server is open source. If you want to know what error codes it returns, read the source code, which you can find by looking around in http://httpd.apache.org/. The official doc does not specify any error codes, so YMMV.
CodeIgniter 2.0.2 syntax error blank page
i have CodeIgniter 2.0.2 (CI) and its annoing, that when i write lots of code and then just get blank page. Hard to debug without error. i got error reporting E_ALL in php.ini and in config of CI its turned on for every case of enviroment (devel, product) just for sure...
Does anyone knows, where the bug can be? How to turn it on? I think CI is rewriting php.ini error reporting setting somewhere somehow...
Thanks.
The other thing to check in your php.ini are the 'display_errors' and 'display_startup_errors' variables, they should both be set to 1.
In my (little) experience with CI this issue has been the most frustating one. I can understand that no framework is perfect, and any web developer is used to deal with errors (no matter if the framework or the developer is to blame). But that ANY error results in a blank page, with ZERO information in logs, console, whatever, is unacceptable.
If I recall correctly, in my case this was caused by of some combination of CI (ab)using the "silent error" PHP operator (e.g. prepending some db statements with the # operator, a not very clever way of avoiding leaking potentially private information to the end user), together with some bad use of *error_reporting*. See my post here (and see how many answers I got!).
I reported another related CI's idiocyidiosyncrasy related with logging here (again, zero answers)
please check the index.php which locate in the SAME LEVEL of the application folder
inside the index.php the second line
line 2:
ini_set("display_errors", "1"); //ensure it is set to 1
line 23:
define('ENVIRONMENT', 'development'); // development | testing | production
grep your php.ini for the word "error", turn them to On etc...
Do you have output compression turned on in the config? I find that will cause white pages when you have errors.
$config['compress_output'] = FALSE; // Should be set to this when developing.
I had the same problem and eventually fixed it when i noticed I had no 'logs' directory in my application folder
i got this error
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header
information - headers already sent by
(output started at
/home/rapcomdk/public_html/system/language/danish/imglib_lang.php:1)
Filename: helpers/url_helper.php Line
Number: 541
i dont know what the problem is
here is my controller:
http://pastebin.com/EMtcMgsB
and here is my model file:
http://pastebin.com/iH6xQFGA
hope some one can help me out
Check and make sure in system/language/danish/imglib_lang.php that you have no whitespace before the <?php tag and make sure you do not have a closing ?> php tag in the file.
In addition to jondavidjohn's answer, if you're using Unicode encoding for the files, make sure there's not a byte order mark starting off the file. On some platforms, this can wreak havoc on PHP processing.
Make sure there are no errors in codeigniter, sometimes the errors can be covered by other errors, such as one error lead to another.
The problem is in system/language/danish/imglib_lang.php, which must have some character before the <?php part by the time it is parsed on the server. What's happening is that helpers\url_helper.php is trying to redirect (using this code;)
case 'refresh' : header("Refresh:0;url=".$uri);
But is failing because imglib_lang.php, line 1 has already sent some non-header text to the response. Since headers come first, it's giving you the warning.
I wonder at it working locally but not on the deployment server. It may be that the file is not being transferred cleanly, or that the servers use different versions of PHP with different handlings of character sets.
Several checks;
Be absolutely sure there is no BOM at the front of system/language/danish/imglib_lang.php. Let us know why you are certain. If you've edited the file in Notepad on windows, for instance, it'll have gained the Byte Order Mark. It can be very hard to tell since some tools 'swallow' the mark. Also make sure there's no plain whitespace.
When you save imglib_lang.php, make sure you save it in ASCII.
Compare local and remote versions of PHP. If there are differences, update your local copy to the same as the servers, and retest.
Check that the file is being transferred perfectly. If you are putting the file up using FTP, then FTP may be modifying it as it transfers it. FTP has two modes - an ASCII mode and a BINARY mode. If the files are being transferred as ASCII, then there may be some rewriting of the file going on. Try making sure imglib_lang.php is being transferred as BINARY to make sure the exact file is being uploaded.
If you think that you have everything configured correctly, maybe your library (or specifically, imglib_lang.php) is simply producing PHP warnings or notices. If you can get a hold of your logs from your host, it would be helpful.
Otherwise, you can try to turn off PHP's error reporting:
error_reporting(0);
(you can place that line in your index.php)