2

Alright so I've been pouring over this code for 16+ hours and I cannot find where the issue is. Before you say anything- I know I'm prone to SQL injection and I need to setup more prepared statements; once I get the code working my next step is to work on those issues. I also know I need to add the TRUE and 303 parameter to the Header call- I'm just trying to get it running at this point.

The code worked beautifully until I began working on eliminating form submission on refresh and adding redirects at the end.

The page that is having the problem is called updateorder.php and here is a Pastie link for it: http://pastie.org/9188291

I created a page called Issue.php to funnel everyone off the page and to eliminate the possibility of any of the html code outputting. That did not help. I removed the ?> PHP closing tag from the end since all the code is PHP and eliminate any white space possibility. That didn't help either.

The page before this has several submit buttons. This page looks at what button was pushed and runs the code when it meets the conditions of the IF.

  • When I submit the form using the DeleteThisOrder button, it operates perfectly.
  • When I submit the form using the PrintOnly button, it operates perfectly.
  • When I submit the form using the UpdateOnly button, but $ThisStatus <>1, it runs perfectly.

Here are the problems:

If I hit the UpdateOnly button and $ThisStatus does ==1, then it remains on this page (updateorder.php) and the screen is blank. The exact thing happens if I use the UpdateCommit button.

Something is happening when it runs this particular section of the UpdateOnly script: Sorry I don't have 10 reputation so it will not let me provide more links. Here is the Pastie number you can replace in the above Pastie link to see the code for this section: 9188298

And something happens when running this particular section of the UpdateCommit script: Sorry I don't have 10 reputation so it will not let me provide more links. Here is the Pastie number you can replace in the above Pastie link to see the code for this section: 9188306

Whatever it is doing it is causing it not to redirect. The SQL code executes and does everything it is supposed to do in the database; it's updating the order, it's updating inventory- all of that executes fine- it's just not redirecting and it stalls somewhere in the script before it redirects and leaves me with a blank screen.

I've done the advanced search on the site and looked at every thing I could find using the keywords PHP, MySQL, Redirect, with no clue as to why it's not working. I've went over this code line by line to look for white space, tried using the whole website address for the redirect, added a space between the colon and the link in the header... I've tried a lot of things. I've even tried unhealthy things like banging my head on my desk, hitting my head with my palm, and pulling my hair... no results. I really appreciate your time.

Just in case- here is the code in my required db connection file: Sorry I don't have 10 reputation so it will not let me provide more links. Here is the Pastie number you can replace in the above Pastie link to see the code for this section: 9188351

By the way... as you can probably tell I'm still learning so it may not be 'beautiful code' yet but I'm working on getting there. Thanks again for your help.

15
  • 4
    white page of death, error reporting\display are off, turn them on error_reporting(E_ALL); ini_set('display_errors', 1); Commented May 19, 2014 at 4:12
  • wow long story! Check your web server log to see if you can find some errors there. Commented May 19, 2014 at 4:16
  • 1
    makk those the first two lines of your file (after <?php) Commented May 19, 2014 at 4:17
  • Just put those 2 lines @Dragon posted in the beginning of the php block. better put it before session_start(); Commented May 19, 2014 at 4:17
  • Try if ($ThisStatus != 1) { instead of if ($ThisStatus <> 1) { see if that makes it kick in. Commented May 19, 2014 at 4:20

1 Answer 1

2

When in development add error reporting to the top of your file(s)

error_reporting(E_ALL);
ini_set('display_errors', 1);

This will signal any errors if they are found in your code.

As per the error message from your comments:

To get rid of that Cannot modify header information - headers already sent... message, place

<?php session_start(); ?><?php // rest of your code... as your first lines of code while getting rid of the other one where it's at now, followed by the rest of your code. Make sure there is nothing above that, HTML etc. including any white spaces. If you still get that error message, make sure it's saved as UTF-8 without BOM. (Consult footnotes)

For the Notice: Undefined index: UpdateOnly error message, make sure your form element is named with no typos. I.e. name="UpdateOnly" --- UpdateOnly is not the same as updateonly PHP is case-sensitive.

As for your $result->free(); you mention you don't have that function, so just remove it.


Footnotes:

  • BOM (aka byte order mark)

For more information on this subject, visit: https://en.wikipedia.org/wiki/Byte_order_mark

For more information on error reporting, visit: http://php.net/manual/en/function.error-reporting.php

Sign up to request clarification or add additional context in comments.

2 Comments

I only had to put <?php session_start(); //and then remainder of code and it functions. I didn't have to close the PHP tag and reopen... but maybe that is a standard I'm not aware of. $result was just the result set from my SQL query execution as in $result = $db->query($sql); The error reporting lines was what led to the solution.
That's great. I'm always glad to hear that. @StatikStasis

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.