|
would the image show if you hadn't the include statement?
it smells like file-not-found, possibly caused by your earlier include-changes-directory issue.
ADDED: does any of your code contain chdir() ?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
mmmm... strange...
If I look at the source code after the web page has been rendered I can see a perfect and correct path...
I've just put the two lines [echo + image] at the beggining of the index page with the same result.
No, I've not found one chdir in the entire site...
[here I'm crying/ranting]
Once again I'm calling (including) the web page from different sources and therefore the path from which it has been called changes and therefore the only way I've found to make everything work is to put complete paths to the files that I know where they are... Then putting "../" before one file is not enough and this is why I'm using this approach.
[just feeling a little bit better]
If I copy the path from the source code after the page has been rendered and then I paste the path into any explorer window the OS shows me the image correctly...
PS: Thank you very much for the patience...
|
|
|
|
|
I suggest you go to the bottom of this, it will haunt you forever if you don't.
I basically see two ways:
1.
install another PHP system and try your web site on it. I use XAMPP on my developing machines. Works great (PHP 5.2.5 + MySQL 5.0.51a)
2.
copy your entire web site and strip it down till you have the smallest one that exhibits the problem, then analyze closely.
Maybe first, if you haven't already, Google for known problems on your PHP system.
Good luck!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
More info:
It does not fail to find the image (I believe) in fact, when an image is not found then a red cross appears.
In this case the red cross is not there as in the place it should be I can see a small white page in which inside there is a red round, a green triangle... It is an image that the OS uses in some cases...
I'm even more confused now...
|
|
|
|
|
this could mean there are two file operations, one succeeding and one failing; maybe the first checks for file existence, the second actually reads the file (I wouldn't do it like that!).
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hello again:
If I try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<div><img src="c:/aaa.png"></div>
</body>
</html>
It fails exactly in the same way...
But in that case it is IE9 who fails... I've only navigated to test.html (which has that content inside) and the result is the same I was telling you...
What I'm doing wrong?
|
|
|
|
|
that looks like a security precaution. Normally a web site is supposed to refer to its own pages, not to the local file system.
And AFAIK XAMPP and other PHP systems also have such (optional?) precautions; mine is set to allow access only to files that are under the server's root.
So what should work is file mypage.html containing
<html>
<body>
<img src="aaa.png">
<img src="images/bbb.png">
</body>
</html>
when it is stored at the site's root, together with aaa.png, and bbb.png in the subdirectory images.
You wouldn't like a web server to give access to files outside its root, would you? The entire file system would be up for grabs.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Working! thank you very much!
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
AAAARGH!
Of course it has worked well from the files that are in the root directory:
- root
-- images
-- templates
How do you solve the fact that there are files that are not in the root folder?
In my case I have index.php as a file that is being used as a template from multiple languages... then it happesn that it is being called (included) from different folders. Once this happens... then problems start...
index.php is at the root folder and it can access without trouble the images that are inside the "images" folder.
but any of the files that is being used inside any of the other folders i.e. index.php (when it is included from another folder) then I would need to use "../images/file.png".
How could I get the root of the web page folder? and then use it in order to load images?
Thank you in advance!
|
|
|
|
|
First of all I try and avoid such situations.
When I can't, require_once("../includes/somefile.php"); works for me. But then I'm not sure what would happen if somefile.php would contain another include or require.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
If I make web site by ASP.net , is it give me the flexibly to make forums and Chat ,Profiles and so on
or PHP is the best?
|
|
|
|
|
m_7tem wrote: PHP is the best?
No, not in my books.
PHP may be the most popular approach, ASP.NET would be the professional approach.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
ASP.NET is better than PHP in my opinion...
|
|
|
|
|
While I would prefer ASP.Net, PHP has the advantage of being able to be hosted on Linux servers. This keeps running costs much lower than ASP.Net servers. Functionally they are pretty much the same, PHP has some funny syntax. ASP.Net has the advantage of being able to use C# as code behind, which would integrate better with desktop applications and WCF(web) services. The choice is ultimately just an arbitrary one, dependant on the developer.
|
|
|
|
|
Having recently moved a site from ASP to PHP I can tell you that ASP was 10x easier for me (but most of my exp until recently in programming has been VB, C#). I was able to get things working a lot faster in ASP and how I wanted them to. Off hand I can't really think of anything I have done in PHP that I thought, "God I'm sure glad I'm using PHP to do this, as it's so much easier".
The only up side is the use of a Linux server for PHP. I'm sure there are other pros and cons, but I work on a web site about 3 hours a month for a intranet site here at work and now just use PHP as I'm forced to (admin won't run IIS).
|
|
|
|
|
|
Hello all,
Here a novice trying to concatenate two strings without luck...
Note: The Document root is "www".
$PATH = $_SERVER['DOCUMENT_ROOT'].'/'; This works wonderfully as I can see "www/".
echo $PATH.'FILE.php'; This should show something like: "www/FILE.php"; but it shows "wwwFILE.php".
Why is this happening?
Any idea on what I'm doing that is not correct?
Thank you in advance.
|
|
|
|
|
|
First of all thank you for answering.
I know that I can put the / just before the file name.
The idea was to avoid that: there are thousands of places with the file name but only a few with the path.
I'd like to know why do this happens. I've not seen this behavior documented anywhere.
Thanks again.
|
|
|
|
|
Have you included ALL your code?
This seems impossible if there is no other code between the two lines.
|
|
|
|
|
Why do you ask if I've included ALL the code? I've included some files in order not to repeat code. There are plenty of situations in which I'm using this.
Do I'm missing something?
Here we go...
I know it seems incredible but it is what it happens...
I'm doing something like:
$path = DOC_ROOT.'/';
echo $path; Here it works well.
but if I'm doing something like:
$path = DOC_ROOT.'/';
$path2 = $path.'folderX'
$path3 = $path.'folderY'
include ($path.file1.php);
include ($path2.file9.php);
here it fails in each include and if I'm trying to get echoed the result it also fails.
As I'm using the paths to include code, I've misunderstood at the beginning... my fault...
[www.tamelectromecanica.com] Robots, CNC and PLC machines for grinding and polishing.
modified on Saturday, March 19, 2011 9:19 AM
|
|
|
|
|
don't you mean
include ($path.'file1.php');
include ($path2.'file9.php');
|
|
|
|
|
Yes, I'm at home now without access to the code (using pseudocode here).
|
|
|
|
|
another suggestion: if you know or can calculate your folder depth (currently requested script's distance from the web root) try this:
$sDepth='../../';
require_once($sDepth.'file1.php');
|
|
|
|