Hi,
I am having a major problem with my php coding.
My site is http://www.mashamoto-imports.com/index.php and I'm trying to implement a multi language script.
The script can be found and is explained here: http://www.bitrepository.com/php-how-to ... bsite.html
Problem is that I get a "headers already sent error", caused by the setcookie and session_start(); function. I have tried everything by moving these functions to make sure they come first on the page. There's no whitespace before the functions and I'm left wondering why it doesn't work.
Weird thing is that the script works perfectly on other pages. I copied the code from index.php and created http://www.mashamoto-imports.com/index2.php Exactly the same scripting used as on index.php!! Why does it work here and not on on the normal index.php?
The script is also installed on http://www.mashamoto-imports.com/cars-for-sale.php Here it also works fine and the setcookie also works as you can see.
I really hope someone can help me out as I need to get this to work asap.
Multi-language script header problem
Moderator: General Moderators
- mecha_godzilla
- Forum Contributor
- Posts: 375
- Joined: Wed Apr 14, 2010 4:45 pm
- Location: UK
Re: Multi-language script header problem
Ok - you could try using an online tool to check the headers - I did a search for "online tool to view web page header" and found this one here:
http://www.seoconsultants.com/tools/headers
Results for index.php are:
[text]#1 Server Response: http://www.mashamoto-imports.com/index.php
HTTP Status Code: HTTP/1.1 200 OK
Date: Fri, 23 Apr 2010 23:27:40 GMT
Server: Apache/1.3.34 (Debian) Sun-ONE-ASP/4.0.2 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.8c
X-Powered-By: PHP/5.2.11-0.dotdeb.0
Transfer-Encoding: chunked
Content-Type: text/html[/text]
Results for index2.php are:
[text]#1 Server Response: http://www.mashamoto-imports.com/index2.php
HTTP Status Code: HTTP/1.1 200 OK
Date: Fri, 23 Apr 2010 23:28:29 GMT
Server: Apache/1.3.34 (Debian) Sun-ONE-ASP/4.0.2 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.8c
Cache-control: private
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Powered-By: PHP/5.2.11-0.dotdeb.0
Set-Cookie: PHPSESSID=c6ae5205dd29ad1cff746dbe2d0eaf9e; path=/
Transfer-Encoding: chunked
Content-Type: text/html[/text]
I also found another tool that's a bit more comprehensive:
http://www.rexswain.com/httpview.html
Judging by the results, it might be a good idea to delete the index.php file on the server, rename your index2.php file to index.php and see what happens.
You should also check that there aren't any blank lines at the end of your index.php file or at the start or end of any included files, and make sure (if you haven't already done so) that there's no HTML/XHTML code before any PHP code, and that session_start() is used before any other code. Also, comparing the source code of the two pages shows that they're not exactly alike so try renaming the index2.php as a starting point.
HTH,
Mecha Godzilla
http://www.seoconsultants.com/tools/headers
Results for index.php are:
[text]#1 Server Response: http://www.mashamoto-imports.com/index.php
HTTP Status Code: HTTP/1.1 200 OK
Date: Fri, 23 Apr 2010 23:27:40 GMT
Server: Apache/1.3.34 (Debian) Sun-ONE-ASP/4.0.2 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.8c
X-Powered-By: PHP/5.2.11-0.dotdeb.0
Transfer-Encoding: chunked
Content-Type: text/html[/text]
Results for index2.php are:
[text]#1 Server Response: http://www.mashamoto-imports.com/index2.php
HTTP Status Code: HTTP/1.1 200 OK
Date: Fri, 23 Apr 2010 23:28:29 GMT
Server: Apache/1.3.34 (Debian) Sun-ONE-ASP/4.0.2 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.8c
Cache-control: private
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
X-Powered-By: PHP/5.2.11-0.dotdeb.0
Set-Cookie: PHPSESSID=c6ae5205dd29ad1cff746dbe2d0eaf9e; path=/
Transfer-Encoding: chunked
Content-Type: text/html[/text]
I also found another tool that's a bit more comprehensive:
http://www.rexswain.com/httpview.html
Judging by the results, it might be a good idea to delete the index.php file on the server, rename your index2.php file to index.php and see what happens.
You should also check that there aren't any blank lines at the end of your index.php file or at the start or end of any included files, and make sure (if you haven't already done so) that there's no HTML/XHTML code before any PHP code, and that session_start() is used before any other code. Also, comparing the source code of the two pages shows that they're not exactly alike so try renaming the index2.php as a starting point.
HTH,
Mecha Godzilla
Re: Multi-language script header problem
ugh ...I feel so stupid. lol. Thanks for pointing that out. Guess there was a difference in the page's coding afterall.so try renaming the index2.php as a starting point.
Many many thanks!!
- mecha_godzilla
- Forum Contributor
- Posts: 375
- Joined: Wed Apr 14, 2010 4:45 pm
- Location: UK
Re: Multi-language script header problem
You're welcome - remember, we all like the easy questions!
Good luck with the site anyway,
Mecha Godzilla
Good luck with the site anyway,
Mecha Godzilla