/    Sign up×
Community /Pin to ProfileBookmark

"No such file or directory" but its there!

hi all!

Im trying to include a CSS file in the header of a php-in-html file and I keep getting this error:

[quote]

[url]http://www.purefan.xennos.com/new/config/css-default.css[/url]
Warning: filesize(): Stat failed for [url]http://www.purefan.xennos.com/new/config/css-default.css[/url] (errno=2 – No such file or directory) in /home/purefanx/public_html/new/top.php on line 34

Warning: fread(): Length parameter must be greater than 0. in /home/purefanx/public_html/new/top.php on line 34
this

[/quote]

now I am printing the value used to open the file: that value is the very first line in the last quote.

Here’s the php code im using:

[code=php]
<?php
echo $_default[“css_path”];
?>

<html><head>
<link REL=”stylesheet” TYPE=”text/css”>

<?php
$myFile = $_default[“css_path”];
$fh = fopen($myFile, ‘r’);
$theData = fread($fh, filesize($myFile));
fclose($fh);

echo $theData;
?>

</head>
<body>this</body></html>
[/code]

the file in question is as you can try out reachable and I set the chmod to 755
I dont know what’s wrong…
any clue?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYMar 05.2006 — what do you want to do anyway?
Copy linkTweet thisAlerts:
@purefanauthorMar 05.2006 — print the content of the css file in the other page, that file is being chosen depending on what the user has specified and stored in a database. But I cannot reach the css file.
Copy linkTweet thisAlerts:
@bokehMar 06.2006 — Well you need to specify the path to your CSS file and you need style elements in the document around the entry point.
Copy linkTweet thisAlerts:
@purefanauthorMar 06.2006 — here's the whole thing:
[code=php]
//top.php
<?php

include("config/funciones.php");

CSS($_SESSION["user"]);

echo $query."<br>".$_SERVER["SERVER_NAME"]."<br>".$_default["css_path"];

?>
<html><head>
<link REL="stylesheet" TYPE="text/css">
<?php
$myFile = $_default["css_path"];
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);

echo $theData;
?>
</head>
<body>this</body></html>
[/code]


[code=php]
//funciones.php
<?php
/*
ARCHIVO FUNCIONES
*/
require_once("variables.php");
require_once("connectar.php");

function CSS($usuario){
if(!empty($usuario)){
$a="SELECT css FROM usuarios";
$result = mysql_query($a);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if($usuario==$row["usuario"]){
return $row["css"];break;}
}//while
}
else return $_default["css"];

}//function CSS

?>
[/code]

[code=php]
//variables.php
<?php

empty($_SESSION["user"]) ? $usuario="" : $usuario=$_SESSION["user"];

$_default = array();

$_default["css"]="css-default.css";
$_default["root"]="http://".$_SERVER["SERVER_NAME"]."/";
$_default["css_path"]=$_default["root"]."new/config/".$_default["css"];
?>
[/code]


So what im trying to accomplish is to be able to call the same template from various files as I will be working with templates that each user will be able to change at will.
Copy linkTweet thisAlerts:
@bokehMar 06.2006 — First I would conentrate on this line:[code=php]$myFile = $_default["css_path"];[/code]Change it to a file path rather than an http path. Also use of SERVER_NAME is dubious to say the least because it bears no direct relationship with the URL of the script in question. SERVER_NAME is the name of the virtual host where you probably are looking for HTTP_HOST.
Copy linkTweet thisAlerts:
@purefanauthorMar 06.2006 — got it! u were right, I changed the variables.php to this and it worked:
[code=php]
$_default["css"]="css-default.css";
$_default["root"]="/home/MyUser/public_html/";//.$_SERVER["SERVER_NAME"]."/";
$_default["css_path"]=$_default["root"]."new/config/".$_default["css"];
[/code]


thanks Bokeh! ?
×

Success!

Help @purefan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...