PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/subdomain/index.php:4) in /home/user/public_html/subdomain/conectar.php on line 22
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/subdomain/index.php:4) in /home/user/public_html/subdomain/conectar.php on line 22
Please notice this part of error:
(output started at /home/user/public_html/subdomain/index.php:4)
and if you were to read your manual on header() you would see that headers need to be sent before _any_ output is sent to browser ( like echo 'something' or even error message that was generated before headers where sent.)
ob_start():
"This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer."
Switching on output buffering so you can send headers after sending page content is a terrible solution. You're going to have increased your server overhead, used much more memory, and slowed everything down simply because you're too lazy to make your script do things in the proper order.
Refactor the code so that the headers are sent before the content. It's not very difficult.