UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Php Debugging Help?    
 
   
strBean
post May 30 2015, 11:13 AM
Post#1


UtterAccess VIP
Posts: 4,892
Joined: 25-September 02
From: Washington State


Hi Gang

I use PHP to make a rinkydink content mgmt system so I can put most content in a MySQL database. I have the script broken up into include files so I can insert special processes for certain pages. For example, there is a Contact Us page that has an extra include containing the <form> etc. That has been working fine for years.

I've attached the files in question in case there's some sharp-eyed PHP-er who'd like to look. In the current challenge (this is for a nonprofit org) there is a page with a form for new members to join the organization, and that page seems to be okay. It's the page named in the action attribute that isn't working. That page is called "new_member_confirmation.php", and it is constructed using all the normal includes except that there is an include named "new_member_conf.inc" inserted just before the include that generates the first line of HTML (DOCTYPE). This include is supposed to finish up the processing in this order:

  • validate the form data
  • write the form data to the $_SESSION variable
  • if there are problems in the data, write HTML prompting user to make corrections to a session variable, to be printed below - no further code should run as it's all inside IF blocks
  • look at the "payMethod" from the form data (PayPal or print form and mail check)
  • if print and mail, write HTML into a variable from the stored membership data, then redirect to a local page that prints that session var data
  • if PayPal, set a $_SESSION var "paid" and then redirect to a PayPal page
  • if the user in fact pays, PayPal links user back to the same page (new_member_confirmation.php) where the script checks whether the "paid" session var is set, and if so, writes the membership data (still in session variable) to a special table in the MySQL database, and displays a Thank You message to the user
  • if the user cancels the payment, PayPal links user back to a different page (new_member_cancellation.php)


So, what happens is:
nothing.

In all my PHP programming, I have been accustomed to receiving error messages back from the server - printed right in the browser window - that help me debug. In this case, when user clicks the Submit button on the form, the new_member_confirmation.php page begins to load and stops. No HTML has been written, at least if I view the source there's nothing there. I'm staring at a white screen.

So, I already know that
header('Location: ' . $newURL);
die();
will only work if no HTML has been printed yet. So I have repeatedly scoured all of the files and I cannot find any issue there. I did find some syntax errors in my script and fixed them but it makes no difference in the result. The odd thing is that there are no error messages.

If you look at the files, it all seems pretty basic. I'm not a hot PHP coder - I don't even know how to write a regular expression. But my stuff has always worked before, and I've always gotten error messages from the server when I had a code problem. No error messages. So, is there something I don't understand about what is allowed in the sandbox?

In the attached zip file, I have added characters to the file names to put them in order. If you open the main PHP file, you'll see the order that the includes are called.

Any help would be greatly appreciated. Or, if someone has an opinion about what is the best PHP forum for this kind of question, please expound.
Attached File(s)
Attached File  php.zip ( 10.97K )Number of downloads: 3
 
Go to the top of the page
 
jleach
post May 30 2015, 01:01 PM
Post#2


UtterAccess Editor
Posts: 9,815
Joined: 7-December 09
From: Staten Island, NY, USA


Hi Sam,

I don't have time to look at the moment, but just curious what you use for an IDE? Eclipse is a decent (free) one that should be capable of step-through debugging (although you typically do have to set up a debugger... xDebug I believe is the typical? I forget offhand, and I use phpStorm rather than Eclipse so not sure offhand how to set up Eclipse for it).

You can take the "messagebox" or "debug.print" style debug approach... in your php code the following:

CODE
echo $someNonArrayVariable;


... which prints the echo to the screen (browser), or...

CODE
print_r($ArrayVariable);"


...which does more or less the same for an array.

(also, I don't recommend die(), myself preferring exit(); instead, for various reasons (mostly due to its' behavior being different pending on how php is configured on the server and general lack of control of session information with die()wink.gif

I'll try to look at the code a little later. Cheers,
Go to the top of the page
 
strBean
post May 30 2015, 04:14 PM
Post#3


UtterAccess VIP
Posts: 4,892
Joined: 25-September 02
From: Washington State


Hah! Just heard back from the hosting service. The latest version of PHP they're using requires that the developer enable error messages to be sent to the browser. That was always turned on before. I've got it turned on now. Geez. All that writing I guess didn't hurt because I made myself make sure I understand my process. But sorry if I wasted anybody's time! I've got error messages now...
Go to the top of the page
 
jleach
post May 30 2015, 08:01 PM
Post#4


UtterAccess Editor
Posts: 9,815
Joined: 7-December 09
From: Staten Island, NY, USA


Glad you got it figured.

Cheers,
Go to the top of the page
 
strBean
post May 31 2015, 02:19 AM
Post#5


UtterAccess VIP
Posts: 4,892
Joined: 25-September 02
From: Washington State


Thanks for being there. Getting the error-messages-to-browser thing turned on was an important key. dazed.gif I'm not very sophisticated when it comes to this web stuff, but simple PHP is easy for me because I like databases.

Anyway, I don't exactly have it figured. I've chased out the remaining syntax errors and the redirects work, etc., but here's the thing:

When the user comes back from PayPal, the session variable is not set. The documentation I read says that the life of the session var is the browser session, but it looks to me like the life of the session var is more like while the browser is connected to that server. Or else if that's not it, what is emptying my session variable? When the user gets back from PayPal there's nothing in $_SESSION. When I think about it, with my pea-brain, it seems like PHP being entirely processed on the server side, how could the session var possibly survive if the only browser window is redirected to a different server? I think that's where my experience falls short - I've never used session vars where it's necessary to go to different server.

Any additional thoughts will be greatly appreciated.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    17th December 2017 - 04:16 PM