I have a problem in my PHP codes I cant find that. because dont display any warning or error and redirect to the main page of my website project and after many test couldnt find problem.
I want to see steps of running the code for example:
get values of $click and $usercode variables===> redirect to request_change.php and run mysql_query with value="select * from users where userid=65643"==> get $username ==> and else...
I can see some running steps by debugging but not exact that I Want and display many error about finding some directories in require_once function but while my webpages display and process information right by wamp.
Is any way to debugging same as that by Phpstorm or any other programs?
OR
How can I run My php code in phpstorm step-by-step and line-by-line??
Update:
I configured phpstorm for debugging but Just I can use debug and select one of page to debug.I checked all the settings steps that were done correctly But The step by step debug buttons is'nt active such as stepOver and step intro and else... In addition, after debugging the codes, the error : PHP Warning: include_once(): Failed opening '.\dref.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\srn\mrt\req_v.php on line 260
is displayed, while the same code works well in the wamp by Firefox
What should I do to solve this problem?
One of the most powerful and useful tools any developer could have is a debugger. I use xDebug myself. With it you can step through a program during execution and watch each method call, every variable value change, and every action the program does. With PHPStorm it is typically very easy to enable / use xDebug. This would be my recommendation for troubleshooting the issue you have.
References:
https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html
https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
https://confluence.jetbrains.com/display/PhpStorm/Xdebug+Installation+Guide
Related
As I am using the local hosting of MAMPbut " There has been a critical error on this website" this is error is coming. What should I do?
Diagnostic steps worth giving a shot, follow from top to bottom order;
Is MAMP really running with Web server (and additionally the database server)?
Do you see the default MAMP index/home screen?
Put a simple HELLO WORLD HTML document to your project root and check if you can see it on browser
Put a simple HELLO WORLD PHP script to your project root and check if you can see it on browser
At this point, if everything above went well, it is definitely an issue with your actual PHP script, check the PHP error log file
Put an INFO.PHP PHP script at your project root and check you have all the required extensions available for your PHP project
Check if database connection is working (if required)
At this point, I cannot imagine what else would go wrong, try PHP debugger (xDebug needs to be installed with MAMP and your PHP editor may need a configuration for this) with break points and step into each line of your PHP code with debugger.
I am trying to debug my php script using PhpStorm and xdebug.
See my xdebug configurations below,
As for the breakpoints, I have added two of them to a simple script which reverses an array,
I debug using the default debug configurations,
The first breakpoint works fine and I am able inspect the variables. But I cannot seem to move the control to the second breakpoint. This is how my screen looks after moving from the first breakpoint and executing line num 14. Line 14 takes in an input from the command line,
So, I tried entering inputs in the console, (can see the 3 i entered)
The debugger looks blank,
I am getting myself familiar with php and xdebug, so I guess the problem should be something trivial. What do you think?
I am starting to use xdebug in combination with qcachegrind and first tests work well. The log file gets recorded and I can open it with qcachegrind. But now I have the issue that I dot't get detailed information for every function. For php::exec_curl I only get the information
"There is no source
available for the following function: php::curl_exec. This is because
its source file cannot be found: php:internal. Add the folder of this
file to the source folder list. This list can be found in the
configuration dialog.
I am using MAMP (/Applications/MAMP/bin/php/php5.6.2/bin/php) on OSX. My first try was to add simply the whole MAMP folder to the source list, but that did not work.
Now I wanted to ask if anybody maybe already had the same challenge and knows how to solve it?
exec_curl is an internal PHP function, meaning that it's been implemented in C and QCacheGrind doesn't have access to it's source nor to any trace of what that function did. For XDebug/PHP/QCacheGrind this function is just a black box, that takes some parameters and returns some input.
Why would you need to see the source? Frankly, you shouldn't care about what happens inside. All internal functions have been tested and proven to work.
I have a problem with PHP. There is an error that I have never encountered before. The home.php, which is the main page of my site, cannot be viewed. And there is nothing in error log. After there is an inclusion of a php page (a class that is a part of my API). Till that line the holl HTML (javascript and css inclusions) are echoed from php and successfully rendered in browser, but after the php kind of stops suddenly. When I delete that line(php page inclusion line), website works, but before, this inclusion didn't make any problem for me. I removed the code parts which after them I encountered this problem, but nothing works.
I am using Apache2, PHP5 with Ubuntu 11.10.
Any help will be appreciated, thanks in advance.
My first hints would be to check the following:
In your script set ini_set('display_errors', '1'); and error_reporting(E_ALL); to display all errors.
Turn on the php error log and check it for errors.
run php -l home.php on the command line to check your php file for syntax errors.
Check Apache's error log, sometimes error messages go there.
If nothing helps use a debbugger like XDebug to see where the script terminates, or alternative insert statements like die("here"); and move them around in your code, to see which parts of your scripts are passed.
Greetings and good luck.
I'm debugging some PHP code written by an outsourcing company (I'm not a PHP guy at all but know the basics; we have an offshore team of PHP developers working for us on this project) that's not working; the code is supposed to be called every 30 minutes by a cron job but its not firing. I tried to run the PHP script via the command line to test if it's working, but it's giving me the following (anonymized) errror:
PHP Fatal error: require_once(): Failed opening required '/myapp/_lib/_classes/MySql.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/myapp/_lib/_base/common.inc.php on line 6
However, the file /var/www/html/myapp/_lib/_classes/MySql.php exists under the proper directory. I'm missing something simple, I'm sure, but like I said I know really nothing beyond the bare basics of PHP and I really need to get this service up and running.
EDIT: The code is using the __autoload() function with all classes in /_lib/_classes
if you start a file name with a slash, it means it's an absolute path. try instead:
require_once('/var/www/html/myapp/_lib/_classes/MySql.php');
Case sensitivity maybe? I've had that problem before.
I'm guessing it's a permissions issue - make sure both your account (for testing purposes) and whatever account cron is going to run your script under (quite possibly yours, but maybe a different one) have read privileges on the file.
Also: the path for the include says /myapp/_lib/_classes/MySql.php, whereas it exists in /var/www/html/myapp/_lib/_classes/MySql.php. Can you change the include to reference the full path?
As said, casing and in addition the correct permissions to access that file are needed.