NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
How to debug php Script at Broswer URL ? (a-la toolbar)


Joined: 30 Jul 2003
Posts: 3
Reply with quote
When I click the PHP URL or submit the Form,I want the script will run at debug mode,How to do this?
I can debug the script at the IDE,but the URL GET or POST Data will be lost at the IDE.
Is there anything like perl ptkdb, at perl mode,when I put "/usr/bin/perl -d:ptkdb " at first line , when the script is request anywhere,the debug window will jump out. But at PHP dbg this will be when some error taken!
Could everyone tell me how to deal ? Thanks very much!
View user's profileFind all posts by saloufengSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 7861
Reply with quote
there are few ways to run debug session with a script being executed as a result of POST or GET request.

1.
you can add debug session request to the form where you run POST or GET.
For example
<form ....>
<input type=hidden name=DBGSESSID value="1@clienthost:7869">
...
</form>

2.
header("Location: http://yourwebhost/yourscript.php?DBGSESSID=1@clienthost:7869");


3.
if your form is in the php script that you were debugging and you got resulted HTML page in the output window, you just press submit on the form to continue debugging. No special actions required. It's done using HTTP cookie.

4.
add DebugBreak() function call somewhere in the script.


Last edited by dmitri on Wed Jul 30, 2003 12:34 pm; edited 1 time in total
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Very good!DebugBreak is working!


Joined: 30 Jul 2003
Posts: 3
Reply with quote
Very Happy ;Thanks very much!
View user's profileFind all posts by saloufengSend private message


Joined: 15 Aug 2003
Posts: 44
Reply with quote
You can make yourself a little "Debug" button in IE like this:

1) Add a new link to the links toolbar.
2) Set the link's target this:
Code:
var str = new String(location);
str += str.indexOf('?') == -1 ? '?' : '&';
str += 'DBGSESSID=1@clienthost:7869'

exactly as it's shown here.
Ignore the warning about javascript not having an handler. IE isn't aware of what it's cabaple of...
3) Change the link's name to whatever you want. for example "Debug with PHP Ed".

Now by clicking this link you will re-run the url you are currently in with all it's query string in debug mode for PHP Ed. From this point on the debug session for that windows will persist, as dimitry pointed out.

There is probably a "cleaner" way to do it by settings cookies from javascript. You can even turn off the debug session that way. But for our humble needs this is quite useful.


Last edited by Post-O-Matic on Tue Aug 19, 2003 11:02 pm; edited 2 times in total
View user's profileFind all posts by Post-O-MaticSend private message


Joined: 15 Aug 2003
Posts: 44
Reply with quote
Here's a "Debug off" javascript code:
Code:
document.cookie = 'DBGSESSID=-1';
document.execCommand('Refresh');

This is IE specific.
View user's profileFind all posts by Post-O-MaticSend private message
Debug button in IE


Joined: 23 Dec 2003
Posts: 5
Reply with quote
Hi, merry christmas to all !!!
i´ve use windows XP e IE 6.0.28 and in my computer the IE does not support the "source javascript" like target of the link button. How can i do that to create a "debug button" in the link´s bar?

tks
View user's profileFind all posts by cleberadrianiSend private message


Joined: 21 Nov 2003
Posts: 39
Reply with quote
Code:

<script>
function goDebug() {
  var str = new String(location);
  str += str.indexOf('?') == -1 ? '?' : '&';
  str += 'DBGSESSID=1@clienthost:7869'
}
</script>
<!-- ----- -->
<a href="javascript:goDebug()">Debug</a>
<!-- OR -->
<input type="button" value="Debug" onclick="goDebug()">

Here's everything you need to execute javascript via a link or a button
View user's profileFind all posts by netgertSend private messageVisit poster's websiteMSN Messenger


Joined: 13 Apr 2004
Posts: 1
Reply with quote
To make a link that appears in the IE Link Bar (Even in IE 6):

Add a page to favorites. Any page will do. Name it something like Debug. Put it in the Link folder.
Edit that bookmark (Right Click and choose prperties). Replace the url with:

javascript: var str = new String(location); str += str.indexOf('?') == -1 ? '?' : '&'; str += 'DBGSESSID=1@clienthost:7869'; document.location = str;

This should all be on one line. Say yes when it warns you.

That will do it. Note, however, that this will only solve your problem if the script uses GET. Because this reloads the page, POST data will be lost (As will HTTP_REFERER, etc.).
View user's profileFind all posts by AndraX2000Send private message


Joined: 22 Sep 2005
Posts: 4
Reply with quote
These will copy over the query string so you don't lose that.

DEBUG OFF: javascript:location.href=location.protocol+'//'+location.hostname+location.pathname+(location.search ? location.search +'&' : '?')+'DBGSESSID=-1'
DEBUG ON: javascript:location.href=location.protocol+'//'+location.hostname+location.pathname+(location.search ? location.search +'&' : '?')+'DBGSESSID=1@clienthost:10001;d=1,p=0'
View user's profileFind all posts by rbarrecaSend private message
How to debug php Script at Broswer URL ? (a-la toolbar)
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic