Installing a WP theme ive made locally to a web server - php

Warning: Cannot modify header information - headers already sent by (output started at /home/content/82/6985782/html/wordpress/wp-content/themes/syntax/themeoptions.php:289) in /home/content/82/6985782/html/wordpress/wp-content/themes/syntax/themeoptions.php on line 136
Thats the error i get whenever i want to submit something in the admin panel.
Here's the code for the themeoptions.php:
http://pastebin.com/aFWHjEv0
It all works perfectly normal on localhost, any explanations??

It's probably output_buffering that is enabled on your local machine, but not on the remote server. (You can find out by using phpinfo).
The easy fix is to prepend your script with a output_buffering command:
<?php
ob_start();
Even better is finding out where the output starts and fix it there.

Related

Where could PHP output which started at php://input:1 be originating from?

Today I tried to login to my wordpress instance which is running on my own server. Upon clicking Login, the page reported the following:
log=admin&pwd=passwort&wp-submit=Log+In&redirect_to=https%3A%2F%2Fwww.mydomain.com%2Fwp-admin%2F&testcookie=1
Warning: Cannot modify header information - headers already sent by (output started at php://input:1) in /var/www/html/wp-login.php on line 504
Warning: Cannot modify header information - headers already sent by (output started at php://input:1) in /var/www/html/wp-login.php on line 520
Warning: Cannot modify header information - headers already sent by (output started at php://input:1) in /var/www/html/wp-includes/functions.php on line 6225
My setup is as follows:
PHP 7.0.15
Wordpress 4.7.1
Nginx, MySql and Wordpress running as docker instances
Another nginx instance that coordinates the routing and redirections (e.g. http -> https)
Name Command State Ports
--------------------------------------------------------------------------------------
wordpress_mysql_1 docker-entrypoint.sh mysqld Up 0.0.0.0:3306->3306/tcp
wordpress_nginx_1 nginx -g daemon off; Up 127.0.0.1:44654->80/tcp
wordpress_wordpress_1 docker-entrypoint.sh php-fpm Up 0.0.0.0:9000->9000/tcp
The thing that bothers me is the source of the output: php://input:1. I tried adding a die('test'); right after the <php opening tag in wp-login.php and to my surprise, the string 'test' appeared AFTER the request string.
Does someone have an idea how I could debug this or where this could possibly be coming from?
For some reason, auto_prepend_file was set to php://input although the default value should be NULL. I could not find where exactly this value was altered but adding auto_prepend_file=NULL to php.ini and restarting the instances fixed this issue.

Godaddy linux server session start

I used godadday linux server for hosting. I write only <?php session_start();?> on my index.php... I also read so many reviews. I tried but there is no solution. I also take support by godaddy supporters. They said that it is coding problem. But I don't use extra code on my page. I don't understand what is going on there.
session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/26/11511826/html/test/index.php:1) in /home/content/26/11511826/html/test/index.php on line 1

PHP session_start(); has started hanging the server

I have a DMZ set up with a web server and an application server, both running Ubuntu under gnome (v11.04 on the web server and v11.10 on the application server). session_start() has started hanging on the application server. The code is located on the application server and it does not hang when I access my web site and access the page with the session_start() call on it. It seems that every session_start() has started hanging on the application server although I have no problems with the associated pages when I access them from other computers or across the web. Also I have only just started having this problem on the application server without having made any changes to my php code. Could it be that some buffer has filled up and needs to be cleared?
I tried editing /etc/php5/apache2/php.ini and setting
session.save_path = "/tmp"
/tmp exists.
But I still have the problem. I can stop it hanging by preceding session_start() with session_end() but then it does not execute the remaining PHP or html code in the file.
/var/log/apache2/error.log included the following message:
PHP Notice: A session had already been started - ignoring session_start() in
/var/www/DraculaPgm.php on line 101, referer:
http://MyWebSite.com/ApplicationServer/Dracula.php
Any assistance with this would be greatly appreciated,
Peter.
Update 29-Dec-2012
Thank you to everyone who replied to this question. Unfortunately, I tried all of the suggestions and 'session_start()' still hangs. However, if I leave it for a few minutes, it breaks with the following error message.
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /ApplicationServer/Dracula.php.
Reason: Error reading from remote server
Apache/2.2.17 (Ubuntu) Server at MyWebSite.com Port 80
I have squid installed on the web server. Could this be a problem?
Thanks,
Peter
This sounds like a configuration issue. Make sure that PHP is reporting all errors, i.e., error_reporting(E_ALL) and either display or log all errors. (You might even want to enable display_startup_errors in your php.ini) - reporting all errors may shed light on what's going on. (if you need help you can post any errors that you get from this as an edit) You may want to look at the following as well for troubleshooting the issues with sessions:
When using /dev/random as session entropy file
When page is calling itself with the same session
Alternatively if none of those show anything you may want to read over the bug report at https://bugs.php.net/bug.php?id=28856&edit=1 depending on what version of PHP you are running.
I changed 'session_start()' to the following block.
if(!isset($_SESSION))
{
session_destroy();
session_start();
}
I now do not have the problem. I am hesitant to say that it fixed the problem since it did not seem to fix it right away.
Thank you to everyone for your help,
Peter.
Try changing the permission of the /tmp folder by doing chmod 777 /tmp and check if its working.If its working then change the permission mode to make it more secure
Try checking out this Question I call session_start() the script hangs and nothing happens
And this http://www.projectpier.org/node/1934
"It seems that the session file is opened exclusively. On some
occasions (Windows) I have found that the file lock is not released
properly for whatever reason, therefore causing session_start() to
hang infinitely on any future script executions. My way round this
problem was to use session_set_save_handler() and make sure the write
function used fopen($file, 'w') instead of fopen($file, 'x')"
You can find many others having the same problem and their workarounds if you go through http://php.net/manual/en/function.session-start.php
if(!isset($_SESSION))
{
session_start();
}
Use this at the top of your PHP file!
And for your info: session_destroy() is used to end session.
Before anything else - try another browser!
I just encountered this session_start problem. I checked my tmp folder and everything and I was about to call my hosting-provider until I thought I should try another browser first because it might have to do with session cookies.
I work with chrome, so I tested in IE and found that it was indeed the case: It worked in another browser!
I closed IE ;) - went back to chrome, looked for the cookie (PHP_SESS_ID), deleted it and everything works again!
Well, the good part is - Just like you guys I got to brush up my knowledge of -jay- sessions! ;)

Migrated from Windows to Linux server, now getting session errors

I recently migrated from a Windows to Linux server... now I am getting a bunch of session warnings and some of the content is being loaded properly. On the Windows server, everything worked smooth and I never had any errors, as soon as the migration to Linux took place, I started getting session warnings such as the one below on every page that uses sessions.
I have no idea what I should try or where to begin to address these problems and would appreciate any advice.
I suspect that if session_start() was actully was the problem, I would have gotten a similar warning on the Windows server.
Also my site is hosted by goaddy and I do not have access to the php.ini file...
Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started
at /home/content/12/9453412/html/mainsearch.php:32)
in /home/content/12/9453412/html/mainsearch.php on line 36
Your problem is, that in
/home/content/12/9453412/html/mainsearch.php line 32
(and possibly also in the following ones) you do some kind of output (echo, print, blanks outside of <?php ... ?> etc.), before you do session_start(); on line 36. This is not allowed, as session_start() wants to send headers which is not possible after some kind of output already occured.
Solution: Put your session_start(); to the top of your php file, or at least before you do any kind of output.
And Michael pointed out correctly that this didn't work correctly on you Windows server either, you just didn't know because error reporting was set not to display warnings.

WP E Commerce Safe Mode restriction error

I have my online shop, created with WP Ecommerce getting broken after I moved it to another server. I could be sure that the problem comes from WP Ecommerce because when I disable that plugin. Everything run as expected. This is the exact error message
Warning: session_start() [function.session-start]: SAFE MODE Restriction in effect. The script whose uid is 515 is not allowed to access /tmp owned by uid 0 in /home/mikalu/public_html/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-constants.php on line 17
Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: files (path: ) in /home/mikalu/public_html/wp-content/plugins/wp-e-commerce/wpsc-core/wpsc-constants.php on line 17
I've tried to turn off safe mode on my php configuration. nothing happens. the error's still there.
I thought it was some kind of permission issue, so I tried to change /tmp permission to 777. Nothing happens. I googled it some more and suspect it might have something to do with fastCGI configuration and stuff. Which I totally don't understand.
My googling result mostly suggest me to consult the web hosting provider or even to move to another host. But in this case, I am the owner of the server (VPS with cPanel/WHM). And I don't have any idea how to solve this kind of problem
Any help would be very much appreciated :)
edit: I'm not so sure of this is really a server issue. Because if it really server configuration issue on session save path. Then the whole wordpress shouldn't be working coz it obviously use some session too. The session problem only come from that particular wp-ecommerce script. That's why I post it here on stackoverflow too.
After your edit, it's more clear why you ask that question. Wordpress itself does not uses PHP session, so it's not causing the issue but those component you're using is using PHP sessions.
The PHP manual normally is a good start to understand safemode and how to disable it: http://php.net/manual/features.safe-mode.php
Additionally you should review your server configuration that it is safe instead. Safe-mode is unsafe. Hopefully your server ain't.

Categories