Current location: Hot Scripts Forums » Programming Languages » PHP » Problem with CSS and PHP working together:(


Problem with CSS and PHP working together:(

Reply
  #1 (permalink)  
Old 03-22-08, 06:13 PM
cssgopher cssgopher is offline
New Member
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Problem with CSS and PHP working together:(

Hey guys,

I'm pretty new here.
Anyways been looking on the net and searching forums for this problem, but can't seem to find anything.

Okay, the problem.


I am trying to use php to write a web page using css. Now I'm pretty sure that I can use basic html and name the file as .php. THe reason it has to be .php is because I have a script I want to put on the page for streaming .rss.

So I wrote out some html, and the css sheet for this page. The problem is that when I try to view the page, all i get is the code displayed back to me, or a page with two links, one for html code, and the other for css code.

I decided to change the document to html to see if it would work then. If the document is .html, it works fine and displays like normal,

but if it's .php then I just get a directory page to the two codes viewable through the browser. I've tried this with mozilla and IE- latest versions.

At first I thought maybe it is the DOCTYPE. I had the DOCTYPE at the top set as if I was using xhtml Strict.

Is there a different doctype I should use for .php and css? I didn't think it mattered.

Anyways, any insights to what could be the problem is greatly appreciated.


cssgopher
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-22-08, 06:39 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
If you are seeing raw php code in your browser it either means that .php files are not being parsed by the web server/php language engine or you don't have proper or working php tags around the php code.

You would need to post your code as a starting point in figuring out what the problem is.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-22-08, 06:41 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
If you post your code, it would help a great deal. We can't read minds. . .yet

EDIT: "Quickfingers" MAB beat me to it
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-22-08, 06:52 PM
cssgopher cssgopher is offline
New Member
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ah. php tags... that could be my problem. I forgot all about the php tags. Dang I feel so retarded right now. I'll try that and see if it works.

You might not have to read my mind after all. lol. jjking.

K' I'll get back to you if it solved the problem.

oops, for some reason I thought I needed php tags at the very beginning and the very ending of the coding like as html is.

Okay, I'm a little confused. I'll have to post the code. THis is just a beggining, as i'm just testing it all out, I haven't really put much content on.


Here is my .php document code:

HTML Code:
<!DOCTYPE html "-//w3C//DTD XHTML 1.0 Strict//EN"
		  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Swing Review</title>
<link href="file:///c:/Users/Cuyler/Documents/My%20Business/Business%20Projects/Simple%20Swing%20Review/Site%20Files/SSR%20CSS%20Style%20Sheet.css" rel="stylesheet" type="text/css">
<html>
<body>

<div id="content">
<tr>
<h1>Weight Loss Tips, Tricks, and Info</h1>
</tr>
</div>

</body>

</html>

and here is my css sheet code:

HTML Code:
#content {position: relative;
          top: 200px;
		  left: 18%;
		  right: 18%;
		  width: 64%;
		  z-index: 3;
		  border-bottom: 1px solid #330099;
		  border-left: 1px solid #330099;
		  border-right: 1px solid #330099;}
		  
h1 {font-family: georgia;
    font-size: 28px;
	font-style: bold;
	color: #FFFFFF;
	text-align: center;
	background-color: #330099;}

Last edited by mab; 03-22-08 at 07:03 PM. Reason: Realized I was confused [mab: Code tags around code please.]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-22-08, 06:54 PM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
lol, if you dont have php tags, it wont be parsing it any time soon
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-22-08, 08:37 PM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
It is not entirely clear from the posted information what you tried or how you are opening the file (though given that the link to your css file, which is a file system path and not a URL and won't work in real life, I would guess you are simply opening this directly in your browser and not through a web server), but here is a little php 101 -

Php is a server side scripting language. In order for you to execute php code, you need a web server with the php language added to it.

Once you have a web server w/php installed and working, when a browser fetches a document ending in an extension (default is .php) that is parsed by the php language engine, the file is read and parsed/executed.

Any content contained in the file that is not between opening and closing php tags - <?php ?> will simply be output to the requesting browser, the same as if php did not exist. Anything between opening and closing php tags - <?php ?> will be parsed and executed by the php language engine as php code and data.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 03-23-08, 11:18 PM
cssgopher cssgopher is offline
New Member
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Ah I understand now.

Okay, thanks, so I need to put everything in php opening and closing tags

Do I also include the DOCTYPE at the top in the php tags?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 03-24-08, 04:31 AM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by cssgopher View Post
Okay, thanks, so I need to put everything in php opening and closing tags

Do I also include the DOCTYPE at the top in the php tags?
Absolutely not. The only thing that goes in between <?php and ?> are PHP statements such as echo, file_get_contents etc. your (X)HTML/CSS etc will not work inside the tags and will cause numerous errors
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CSS within PHP file Problems!! Help... :( albobis CSS 6 05-24-06 08:26 PM
Css and php not working together homeboy PHP 0 12-23-05 05:28 PM
Use of CSS within PHP CutAndPaste PHP 5 07-11-05 08:27 AM
PHP and CSS Expert NEEDED!!!! eFutureMedia Job Offers & Assistance 1 09-11-04 02:53 PM
PHP and CSS Expert NEEDED!!!! eFutureMedia PHP 4 09-11-04 09:34 AM


All times are GMT -5. The time now is 07:28 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.