icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.
Old July 31st, 2007, 1:37 PM   #1 (permalink)
Registered User
Seasoned Poster
 
Joined in Mar 2007
36 posts
Gave thanks: 3
Thanked 0 times
PHP Counter Problem

I'm writing a simple counter program in php to include on my website. I threw this together real quick and the file handling works perfectly, but my images aren't displaying and I'm just not seeing why. I'm getting the dreaded white box with the red 'x' through it. The line of code on my main page is:

<?php include("/home/account/public_html/counter/counter.php"); ?>


counter.php is as follows:
<?php
$fp = fopen("/home/account/public_html/counter/counter.txt" , "r");
$count = (int)fread($fp, 1024);
$count++;
fclose($fp);
for ($i = 0 ;$i < strlen($count) ; $i++)
{
$imgsrc = substr($count,$i ,1);
//display the image(s)
echo "<img src =\"/home/account/public_html/counter/" . $imgsrc . ".GIF\">";
}
$fp = fopen("/home/account/public_html/counter/counter.txt", "w");
fwrite($fp, $count);
fclose($fp);
?>

The images are 0.GIF, 1.GIF, etc.

Can anyone see why these wouldn't be displaying? I just need another pair of eyes to look at it at this point.
jacker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 31st, 2007, 1:47 PM   #2 (permalink)
He shoots.. He scores!
Super #1
 
puckchaser's Avatar
 
Joined in Feb 2007
Lives in A room with no windows.
Hosted on SH110
1,449 posts
Gave thanks: 46
Thanked 140 times
Can you call the images directly in your browser?

http://domain.com/counter/1.GIF ?

Also, are your GIF extensions UPPER CASE , lower case or Mixed Case?
__________________
SH110
puckchaser is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 31st, 2007, 1:55 PM   #3 (permalink)
Registered User
Seasoned Poster
 
Joined in Mar 2007
36 posts
Gave thanks: 3
Thanked 0 times
I can access the images directly in my browser from http://domain.com/counter/1.GIF .

And my file extensions are all upper case such as .GIF
jacker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old July 31st, 2007, 3:23 PM   #4 (permalink)
Race Surpass
Super #1
 
MarkRH's Avatar
 
Joined in Jul 2006
Lives in Oklahoma City, OK
Hosted on sh102
1,227 posts
Gave thanks: 18
Thanked 86 times
change
PHP Code:
//display the image(s) 
echo "<img src =\"/home/account/public_html/counter/" $imgsrc ".GIF\">";

to:
PHP Code:
//display the image(s) 
echo '<img src="/counter/' $imgsrc '.GIF">';

Must remember, when sending stuff to the browser such as images and URL links, the "root" is public_html. That should solve it. Oh, I also changed the double quotes on the outside of the echo to single quotes so you don't have to escape the inside double quotes. The important thing is changing the image path in the src attribute.

Hope that helps.
MarkRH is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
This user thanks MarkRH for this great post!
jacker (July 31st, 2007)
Old July 31st, 2007, 4:25 PM   #5 (permalink)
Registered User
Seasoned Poster
 
Joined in Mar 2007
36 posts
Gave thanks: 3
Thanked 0 times
Thanks so much! I knew it had to be something obvious that I was missing. Works great now!
jacker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

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