Register FAQ/Rules Forum Spy Search Today's Posts Mark Forums Read

Welcome to the Mac Forums forums. Please read the FAQ if you have questions. Register to participate.

 
Go Back   Mac Forums > Special Interests > Web Design and Development
TouchArcade.com - iPhone Game Reviews and News

Reply
 
Thread Tools Search this Thread  
Old Jun 1, 2007, 11:14 AM   #1
odinsride
macrumors 6502a
 
odinsride's Avatar
 
Join Date: Apr 2007
Location: Reston, VA
Odd CSS problem

Hi all, first post in this subforum.

I am trying to get back into PHP/CSS/etc, and having a little problem with something - on my web hosting, my CSS is not working at all, however when I access my site locally through Xampp, it shows up fine. Any ideas what could cause this? Here's the code:

header.php
HTML Code:
<html>
  <head>
    <title>Sound Void</title>
	<link rel="stylesheet" type="text/css"  href="css/formatting.css" />
  </head>
  
  <body>

    <div id="header"><?php
					   include("title.html");
					 ?></div>
    <div id="divider"><?php include("topnav.html"); ?></div>
	<div id="content">
index.php
PHP Code:
<?php 
session_start
();
header("Cache-control: private");
include (
"header.php");
include (
"db.php");

$count 0;
$sql "SELECT news_id, headline, text, date_posted, user_name FROM music_news";
$result=mysql_query($sql);
$rows=mysql_numrows($result);
mysql_close();

$i=0;

while(
$i $rows) {
        
$id mysql_result($result,$i,"news_id");
    
$headline mysql_result($result,$i,"headline");
    
$text mysql_result($result,$i,"text");
    
$date mysql_result($result,$i,"date_posted");
    
$user mysql_result($result,$i,"user_name");
    
    if (
$count 0){
        echo 
'<hr />';
    }

    echo 
'<h2>' $headline '</h2>';
    echo 
'<div id=newstext>';
    echo 
$text '</div>';
    echo 
'<h5>Posted by ' $user ', ' $date;
    if (
$_SESSION['group'] == 1){
        echo 
' || <a href=edit_news.php?id=' $id '>Edit</a>';
    }
    if (
$_SESSION['group'] == && $_SESSION['dbuser'] == $user){
        echo 
' || <a href=edit_news.php?id=' $id '>Edit</a>';
    }
    if (
$_SESSION['group'] == 1){
        echo 
' || <a href=delete.php?id=' $id '>Delete</a>';
    }
    echo 
'</h5>';


    
$count $count+1;
    
$i++;
  }
include (
"menus.php");
include (
"footer.php");
?>
As you can see, the index.php calls the header file with an include. The other stuff from the header file shows fine. The page displays everything it should other than the formatting.


Also, while I'm here, what does everyone here use for editing PHP/html on a mac? I was working with Vim last night but it doesn't seem to have color coding, which I prefer for writing code. Suggestions?
__________________
"It is just that heavy metal musicians write in minor keys, and when you do that, you frighten people." - Ronnie James Dio
Flickr
odinsride is offline   Reply With Quote
Old Jun 1, 2007, 11:23 AM   #2
plinden
macrumors 68040
 
plinden's Avatar
 
Join Date: Apr 2004
If it works locally but on when hosted, it's likely an issue with the path to the css file. The request for the css ("css/formatting.css") is probably not being resolved to the location you expect. Try using a path relative to your header.php.

I get syntax color with vim and gvim, but then I've been using the same .gvimrc and .vimrc files for years, copying from machine to machine, and I don't really know what's different between my rc files and the defaults.

Actually, I just remembered. Try typing ":syntax on" when you're editing. You can add that to .vimrc
and .gvimrc. I prefer gvim, by the way. Edit: I've uploaded my .gvimrc and .vimrc if you want to take a look. Copy gvimrc.txt to your home directory as .gvimrc and vimrc.txt as .vimrc (backup your own copies first, if you have them)

I've also used TextWrangler, which has syntax highlighting. It works well, but my fingers still keep trying to do the vi commands.
Attached Files
File Type: txt vimrc.txt (2.4 KB, 19 views)
File Type: txt gvimrc.txt (1.8 KB, 13 views)

Last edited by plinden : Jun 1, 2007 at 11:28 AM.
plinden is offline   Reply With Quote
Old Jun 1, 2007, 02:10 PM   #3
odinsride
Thread Starter
macrumors 6502a
 
odinsride's Avatar
 
Join Date: Apr 2007
Location: Reston, VA
Quote:
Originally Posted by plinden View Post
If it works locally but on when hosted, it's likely an issue with the path to the css file. The request for the css ("css/formatting.css") is probably not being resolved to the location you expect. Try using a path relative to your header.php.

I get syntax color with vim and gvim, but then I've been using the same .gvimrc and .vimrc files for years, copying from machine to machine, and I don't really know what's different between my rc files and the defaults.

Actually, I just remembered. Try typing ":syntax on" when you're editing. You can add that to .vimrc
and .gvimrc. I prefer gvim, by the way. Edit: I've uploaded my .gvimrc and .vimrc if you want to take a look. Copy gvimrc.txt to your home directory as .gvimrc and vimrc.txt as .vimrc (backup your own copies first, if you have them)

I've also used TextWrangler, which has syntax highlighting. It works well, but my fingers still keep trying to do the vi commands.
Thanks for the vim tips.

As for the relative path, that path is correct. header.php resides in the same directory that also contains the css folder. I kept the directory structure in tact when uploading to my server. I don't see why this isn't working unless it could be a permissions issue. Is this likely?
__________________
"It is just that heavy metal musicians write in minor keys, and when you do that, you frighten people." - Ronnie James Dio
Flickr
odinsride is offline   Reply With Quote
Old Jun 1, 2007, 02:20 PM   #4
plinden
macrumors 68040
 
plinden's Avatar
 
Join Date: Apr 2004
What do you get when you type http://host/path/css/formatting.css ... where host is your hosted server, and path is the the path to your header.php (which may be empty)?

If your page isn't loading the css file, the path to it likely to be wrong, no matter what you think is right. I've had this issue myself, and modifying the path usually fixes it. This is especially an issue where you're including a file containing the link to a css or image.

If your directory structure is like:

Code:
|- header.php
|- css
    |- formatting.css
try changing your css path to "./css/formatting.css"
plinden is offline   Reply With Quote
Old Jun 1, 2007, 04:45 PM   #5
odinsride
Thread Starter
macrumors 6502a
 
odinsride's Avatar
 
Join Date: Apr 2007
Location: Reston, VA
Quote:
Originally Posted by plinden View Post
What do you get when you type http://host/path/css/formatting.css ... where host is your hosted server, and path is the the path to your header.php (which may be empty)?

If your page isn't loading the css file, the path to it likely to be wrong, no matter what you think is right. I've had this issue myself, and modifying the path usually fixes it. This is especially an issue where you're including a file containing the link to a css or image.

If your directory structure is like:

Code:
|- header.php
|- css
    |- formatting.css
try changing your css path to "./css/formatting.css"

I get this message trying to go to the css file directly:

Quote:
Forbidden

You don't have permission to access /sandbox/css/formatting.css on this server.

Also, I've tried the ./css/formatting.css as well with the same results.
__________________
"It is just that heavy metal musicians write in minor keys, and when you do that, you frighten people." - Ronnie James Dio
Flickr
odinsride is offline   Reply With Quote
Old Jun 1, 2007, 04:47 PM   #6
odinsride
Thread Starter
macrumors 6502a
 
odinsride's Avatar
 
Join Date: Apr 2007
Location: Reston, VA
Wow, I just fixed the problem by giving the folder chmod 755...I wonder why it didn't have these permissions by default.
__________________
"It is just that heavy metal musicians write in minor keys, and when you do that, you frighten people." - Ronnie James Dio
Flickr
odinsride is offline   Reply With Quote

Reply

Mac Forums > Special Interests > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:48 AM.

Mac News | Mac Rumors | iPhone Game Reviews | iPhone Apps

Powered by vBulletin® Version 3.6.10
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 2002-2009, MacRumors.com, LLC