12 Replies
every time i bulid a website with php and i put it in host
some of header and redirect wont work
even if name are fix
but in localhost are fine
what should i do do fix this problems and how detect it beffor puting it in website
like in this part
https://nimakhadivar.ir/nima/main/dashboard/result.php
it should redirect user to another page but it will stuck and dont do anything
you should install xdebug and the xdebug extension in your ide/editor
is that everything in the file? Nothing above the
<?php
? Not even a space or a newline?
no errors in the log for the mysql connection?
cause if that fatal-errors out that header line is never going to run
I'm guessing there is stuff, cause $user_id
isn't defined anywhere herethis does stink to "utf-8 bom" or just bad code
this only redirects if there's nothing in the database
but the way it's written is very hard to follow
yeah, the variable names aren't great
it should be
exam_count
or exam_total
and the as
should match the variable name in PHP
or number_of_exams
would work tooand it is receiving potential user data without prepared statements
which is excusable if the $user_id comes from a fully trusted source (like a prepared statement earlier), or a session in a pinch, but not from any of the superglobals
we actually don't know
it's possible the bug is there
if there's a bug where the user id is always set to the same value, this will always return the same result
even when the user logged in is different
I'm half-suspecting "local" meaning "PHP Built-in server" and hosted is apache/nginx with php-fpm or something, and they handle headers just differently enough for a blank line before <?php to not be an issue in one and an issue in the other
but yeah, check the error log, if that doesn't work, install xdebug
oh, yeah, apache flips as soon as you send a single character and then call
header()
or just turn on show_errors
and restart the server when you do it