May 19, 201115 yr I made a formatted php page. like css with php. For some reason the page is blank and when i check the source code there is none. it may be problems with my server, but i hope not. Please help. Edited May 19, 201115 yr by wolf125
May 19, 201115 yr Not too sure what you mean but chances are there is an error in your code and you have error reporting off so you just get a blank screen. Switch error reporting on.
May 19, 201115 yr Author I don't know how. What would i even mess with. My server, my code, what? Edited May 19, 201115 yr by wolf125
May 19, 201115 yr post code or switch error reporting on and post error otherwise nobody can help you.
May 19, 201115 yr Author post code or switch error reporting on and post error otherwise nobody can help you. Post to this site?
May 19, 201115 yr Author Here it is: <? $agent = getenv("HTTP_USER_AGENT"); if (preg_match("/Win/i", "$agent")) { $style = "win"; } else if (preg_match("/Linux/i", "$agent")) { $style = "linux"; } $win_style = "<style type=\ "text/css\">p, ul , ol, li {font-family:Arial;font-size:10pt;font-wheight:normal;} h1 {font-family:Arial;font-size:16pt;font-wheight:bold;} h2 {font-family:Arial;font-size:14pt;font-wheight:bold;} strong {font-family:Arial;font-size:10pt;font-wheight:bold;} em {font-family:Arial;font-size:10pt;font-style:italic;} </style>"; $linux_style = "<style type=\"text/css\"> p, ul, ol, li {font-family:Times;font-size:12pt;font-wheight:normal;} h1 {font-family:Times;font-size:18pt;font-wheight:bold;} h2 {font-family:Times;font-size:16pt;font-wheight:bold;} strong {font-family:Times;font-size:12pt;font-wheight:bold;} em {font-family:Times;font-size:12pt;font-style:italic;} </style>"; ?> <html> <head> <title>Platform Matching</title> <? if (style == "win") { echo "$win_style"; } else if ($style == "linux") { echo "$linux_style"; } ?> </head> <body> <h1 align=center>This is a level 1 heading</h1> <h2 align=center>This is a level 2 heading</h2> <p align=center>This is a simple paragraph with some <strong>bold</strong> and <em>emphasized</em> text.</p> </body> </html>
May 19, 201115 yr Add this to the top (inside php tags of course) ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); I notice there are 2 instances where you have added a space between else & if Edited May 19, 201115 yr by Blofeld
May 19, 201115 yr Author Also, remove the space between else & if And perhaps change <? to <?php those have worked for my php before, and also i still don't see anything when i try. i am almost certain it is a server error.
May 19, 201115 yr those have worked for my php before, and also i still don't see anything when i try. i am almost certain it is a server error. Which? The short tags or leaving a space?
May 19, 201115 yr Author Add this to the top (inside php tags of course) ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); I notice there are 2 instances where you have added a space between else & if thanks again, but still nothing. all there is is a blank screen and no code. i have checked if i didn't type in the right address, but it seems to be right after 4 or 5 times and i am convinced it's the server or something else. correct me if I'm wrong though.
May 19, 201115 yr Author Which? The short tags or leaving a space? both work for both ways, but not on when i look it up after posting it through my server.
May 19, 201115 yr The only other error I can see is the space between \ and " $win_style = "<style type=\ "text/css\"
May 19, 201115 yr And if the error reporting code I posted doesn't work you need to do it from within your php.ini file (if there ain't one, create one. You should always develop with error reporting on otherwise you'd be at it forever! Inside php.ini error_reporting = E_ALL display_errors=On Edited May 19, 201115 yr by Blofeld
May 19, 201115 yr Author Thanks man. That last one fixed it. The oddest thing though is how that would keep me from viewing the source code. any idea on that??
May 19, 201115 yr Because you have error reporting set to 'off'! If php has a fatal error the page won't load anything. If you have it switched 'On' it would show the error and line number.
May 19, 201115 yr Author that's odd. it's doing it again. it was right after your last bit of code. Edited May 19, 201115 yr by wolf125
May 19, 201115 yr that's odd. it's doing it again. it was right after your last bit of code. Again!!! This: And if the error reporting code I posted doesn't work you need to do it from within your php.ini file (if there ain't one, create one. You should always develop with error reporting on otherwise you'd be at it forever! Inside php.ini error_reporting = E_ALL display_errors=On
May 19, 201115 yr Author your very last bit of code did the same thing, because when i took it out it worked perfectly.
May 19, 201115 yr Again!!! This: Sorry for butting in Blofeld, but this should solve his problems <?php $agent = getenv("HTTP_USER_AGENT"); if (preg_match("/Win/i", "$agent")) { $style = "win"; } else if (preg_match("/Linux/i", "$agent")) { $style = "linux"; } $win_style = "<style type=\"text/css\">p, ul , ol, li {font-family:Arial;font-size:10pt;font-weight:normal;} h1 {font-family:Arial;font-size:16pt;font-weight:bold;} h2 {font-family:Arial;font-size:14pt;font-weight:bold;} strong {font-family:Arial;font-size:10pt;font-weight:bold;} em {font-family:Arial;font-size:10pt;font-style:italic;} </style>"; $linux_style = "<style type=\"text/css\"> p, ul, ol, li {font-family:Times;font-size:12pt;font-weight:normal;} h1 {font-family:Times;font-size:18pt;font-weight:bold;} h2 {font-family:Times;font-size:16pt;font-weight:bold;} strong {font-family:Times;font-size:12pt;font-weight:bold;} em {font-family:Times;font-size:12pt;font-style:italic;} </style>"; ?> <html> <head> <title>Platform Matching</title> <?php if ($style == "win") { echo ($win_style); } else if ($style == "linux") { echo ($linux_style); } ?> </head> <body> <h1 align=center>This is a level 1 heading</h1> <h2 align=center>This is a level 2 heading</h2> <p align=center>This is a simple paragraph with some <strong>bold</strong> and <em>emphasized</em> text.</p> </body> </html> Pat
May 19, 201115 yr Author what does php.ini mean? I'm sorry. I am a severe case of programming noobness.
May 19, 201115 yr just create a file called php.ini in the same directory as the file you are working on and add those 2 lines. It is how you change php config settings.
May 19, 201115 yr Cheers Pat! I suppose I should have just done that in the first place...I just thought it best he knew which bits were causing the trouble.
May 19, 201115 yr Author well it does work. thanks guys. although i don't know what php.ini means. if it wouldn't be too much trouble, what is it?... never mind,. you guys type fast Edited May 19, 201115 yr by wolf125
May 19, 201115 yr Author Blofeld. you should know that i just checked his code against mine and fixed it. I don't just copy and paste.
May 19, 201115 yr Author you guys know how to make a code have an ini file extension? actually, dont reply. I'll just make a new topic. I should have done that earlier. if you want to look it will be ini extention Edited May 19, 201115 yr by wolf125
Create an account or sign in to comment