This topic is locked
[SOLVED]

 How to properly debug

10/24/2011 10:23:39 AM
PHPRunner General questions
N
notuo author

I have this issue:
I am coding some event (after record updated) and is not working fine. I have all the "echo" statements ready an even sometimes I have echo "str", exit();
The thing is. I never get the echo results in the screen. Also using firebug I noticed a some error (in an url URL&error or something) in the result but then a refresh of the page came up )(almost immediately) and I cannot see what is the problem.
Any hint you may share to solve this?

C
cgphp 10/24/2011

Probably you are using popup for add/edit pages. Enable firebug and check the response from the server in the Net tab.

P
procheck 10/24/2011

I highly recommend Code Lobster for PHP debugging. You can step through your code and there is no need for echoing output.

It's free for basic php debugging and they have a small charge for add-ons like Drupal.

N
notuo author 10/24/2011



Probably you are using popup for add/edit pages. Enable firebug and check the response from the server in the Net tab.


Cristian, no, I am not using pop ups and I have firebug with the net tab. There is where I noticed the flash of the error.



I highly recommend Code Lobster for PHP debugging. You can step through your code and there is no need for echoing output.

It's free for basic php debugging and they have a small charge for add-ons like Drupal.


Thanks for this hint. I'll try later today. I'll have to check how to do this. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=61664&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' />

N
notuo author 10/25/2011



I highly recommend Code Lobster for PHP debugging. You can step through your code and there is no need for echoing output.

It's free for basic php debugging and they have a small charge for add-ons like Drupal.



Hi again. I installed codelobster but I cannot figure how to do this debug/breakpoint thing (they have a manual?)
What I was able to do is to set the breakpoint in the tablename_events.php page and call tablename_add.php but nothing happens.
I am testing locally and the debug home url doesn't do anything, so I used the F5 (debug now) but this opens the browser.
If you have some time, can you share any advice on how to do this?
Best regards,
I'll keep looking at this.

C
cgphp 10/25/2011

Please, post the error you get in firebug and post also the code of the "After record updated" event.

P
procheck 10/25/2011

For Code Lobster:
You need to have Apache running. Contact their support. They will help get you going.

N
notuo author 10/25/2011



Please, post the error you get in firebug and post also the code of the "After record updated" event.


I finally got what the error is. An null value in a table cause it, but here are the screens I mentioned before (the first one with the error and the second one just moments later).
img1
img2



For Code Lobster:
You need to have Apache running. Contact their support. They will help get you going.


Yes I have it running fro all my testings. I already contacted support. Apparently is not working for me. I hope the can help.
Thanks

C
cgphp 10/25/2011

Expand the link (POST facturasemitidas_add.php?error....) in firebug to see the server response.

N
notuo author 10/25/2011

Cristian, I cannot do that. The screen refresh within seconds and I don't have the chance to do anything.
This is part of the problem. I had no real information to track down this.
I don't know why the "exit();" I have in the following code doesn't work at all.

$strSQLExists = "SELECT * FROM casos WHERE factura='" . $values["facturaID"] . "'";

$rsExists = db_query($strSQLExists, $conn);

$data = db_fetch_array($rsExists);

$msg .= "Data: \n" . $data;

if($data) {

$sicologa1 = $data["psicologa1ID"];

$sql1 = "SELECT cuota from tabuladores WHERE costoID=" . $data["costo1"];

$rslt1 = db_query($sql1, $conn);

$data1 = db_fetch_array($rslt1);

$cuota1 = $data1["cuota"];

$caso = $data["casosID"];

$sql2 = "INSERT INTO pagos (facturaID, casoID, sicologaID, fecha, numcheque, cantidad) VALUES (" . $values['facturaID'] . "," . $caso . "," . $sicologa1 . ", 0, 0, " . $cuota1 . ")";
db_exec($sql2, $conn);
$sicologa2 = $data["psicologa2ID"];

if ($sicologa2 <> 0) {

$sql2 = "SELECT cuota from tabuladores WHERE costoID=" . $data["costo2"];

echo $sql2 . "\n";

$rslt2 = db_query($sql2, $conn);

$data2 = db_fetch_array($rslt2);

$cuota2 = $data2["cuota"];

$sql2 = "INSERT INTO pagos (facturaID, casoID, sicologaID, fecha, numcheque, cantidad) VALUES (" . $values['facturaID'] . "," . $caso . "," . $sicologa2 . ", 0, 0, " . $cuota2 . ")";

db_exec($sql2, $conn);
echo $sql2 . "\n"; exit();
}

} else { echo "Error: get factura: <br/>";}
C
cgphp 10/25/2011

If factura is an integer remove from the query the single quotes:

global $conn;

$strSQLExists = "SELECT * FROM casos WHERE factura=" . $values["facturaID"];


Click the Persist button in firebug (you can see it in the first image) to keep errors after a refresh.

N
notuo author 10/25/2011



If factura is an integer remove from the query the single quotes:

global $conn;

$strSQLExists = "SELECT * FROM casos WHERE factura=" . $values["facturaID"];


Click the Persist button in firebug (you can see it in the first image) to keep errors after a refresh.


About the quotes, I already removed them, but there wasn't the factor of the error. I had a null value in $data["costo2"] and therefore the error.
Thanks for the persist tip. I tried in another situation and works fine. This would helped me a lot in this case <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=61706&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />
Regards

P
procheck 10/25/2011

It should be: "SELECT * FROM casos WHERE factura='".$values["facturaID"] ."'";
It is hard to read. Single quote then double quote. It finishes with double, single quote, then double.
For Code Lobster, I use these settings. Your PHP code must be located in a folder under htdocs.

To run it, Debug\Debug URL. In the URL Dialog it should be http://localhost/'>http://localhost/ .

(In my case it is http://localhost:8080/ because that's how I set it up at the time)
Virtual Folder: C:\Apache2.2\htdocs

Virtual Host URL: http://localhost/'>http://localhost/

Path to php.ini: C:\PHP

PHP Version: PHP_5.3.x_VC9_Thread_Safe

Port 6000
Web Server is blank

C
cgphp 10/26/2011



It should be: "SELECT * FROM casos WHERE factura='".$values["facturaID"] ."'";
It is hard to read. Single quote then double quote. It finishes with double, single quote, then double.



Single quotes are for text fields. Factura is an integer. The correct query is the following:

$strSQLExists = "SELECT * FROM casos WHERE factura=". $values["facturaID"];
N
notuo author 10/26/2011



For Code Lobster, I use these settings. Your PHP code must be located in a folder under htdocs.

To run it, Debug\Debug URL. In the URL Dialog it should be http://localhost/'>http://localhost/ .

(In my case it is http://localhost:8080/ because that's how I set it up at the time)
Virtual Folder: C:\Apache2.2\htdocs

Virtual Host URL: http://localhost/'>http://localhost/

Path to php.ini: C:\PHP

PHP Version: PHP_5.3.x_VC9_Thread_Safe

Port 6000
Web Server is blank


Codelobster people helped me and today is working the debugger. I tried with a simple script.
I like the breakpoint in the events page and run from the calling _add page.
Thanks. Looks promising.



Single quotes are for text fields. Factura is an integer. The correct query is the following:

$strSQLExists = "SELECT * FROM casos WHERE factura=". $values["facturaID"];



This is the one I am using. The latest I share was wrong.
Thank you both.

P
procheck 10/26/2011

Sorry Cristian. I forgot about that. Some of numbered data I receive is in text format.