Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 3:34 PM   #1
Balbino Brito
 
Balbino Brito's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

Hello Everyone.

I´m trying to make a counter in my server BUT I would like to call it FROM
ANOTHER SERVER.

Let me explain this a little further:

Suppose I have a PHP-IIS Server working properly with an script called
counter.php. We´ll call this server NUMBER ONE

I want to show the counter on an HTML page that is hosted ON ANOTHER SERVER,
not mine. (I can upload the html though). We´ll call this server NUMBER TWO.

Now, I created an html page called default.htm calling the script using:

<p>
<script language="JavaScript1.2" type="text/javascript"
src="www.NUMBERONE.COM/counter.php"> </script>
</p>

And I stored the HTML file on the NUMBER TWO server.

Now, I want to open the url http://WWW.NUMBERTWO.COM/default.htm and I want
it to show the IMAGES from MY counter ON NUMBER ONE!

Now, the problem I´m having is that the counter INCREMENTS ITSELF when I
open the page, BUT IT DOESN´T SHOW THE IMAGES...

If I open HTTP://WWW.NUMBERONE.COM/COUNTER.PHP it shows all the images
properly.

Now, I´m a Newbie and I have no clue of what is going on here... Can anyone
help me???

I don´t know if the problem is in my html file or in my php script...

Help!!!

BB

<?php
include ("parameters.inf");
$vdigits = 1;
if (file_exists("$datafile")) {
$fp = fopen("$datafile", "r+");
flock($fp, 2);
$count = fgets($fp, 4096);
$count += 1;
fseek($fp,0);
fwrite($fp, $count);
flock($fp, 3);
fclose($fp);
} else {
echo "Your Counter.dat file is missing '\$file' var...<BR>";
exit;
}
$count=chop($count);

$vdigits = max(strlen($count), $vdigits);

$count = substr("0000000000".$count, -$vdigits);

$varreglo = preg_split("//", $count);

for($i = 0; $i <= $vdigits; $i++) {
if ($varreglo[$i] != "") {
echo "<IMG SRC=\"$imgdir$varreglo[$i].gif\" border=\"0\"
alt=\"$varreglo[$i]\">";
}
}
?>


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 07-01-2007, 3:34 PM   #2
Balbino Brito
 
Balbino Brito's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

It´s worse than i thought.

I created an script called hello.php and I created an html with the

> <p>
> <script language="JavaScript1.2" type="text/javascript"
> src="www.NUMBERONE.COM/hello.php"> </script>
> </p>


The hello.php only has

<?php
echo "Hello Nurse!"
?>

When I browse from number one, it shows the message, but when i browse from
www.numbertwo.com/hello.htm it doesn´t.

So, now I´m really frustrated.

Help anyone, please!

Thanks in advance.



"Balbino Brito" <nospam@please.com> escribió en el mensaje
news:bel46e$644ae$1@ID-197907.news.uni-berlin.de...
> Hello Everyone.
>
> I´m trying to make a counter in my server BUT I would like to call it FROM
> ANOTHER SERVER.
>
> Let me explain this a little further:
>
> Suppose I have a PHP-IIS Server working properly with an script called
> counter.php. We´ll call this server NUMBER ONE
>
> I want to show the counter on an HTML page that is hosted ON ANOTHER

SERVER,
> not mine. (I can upload the html though). We´ll call this server NUMBER

TWO.
>
> Now, I created an html page called default.htm calling the script using:
>
> <p>
> <script language="JavaScript1.2" type="text/javascript"
> src="www.NUMBERONE.COM/counter.php"> </script>
> </p>
>
> And I stored the HTML file on the NUMBER TWO server.
>
> Now, I want to open the url http://WWW.NUMBERTWO.COM/default.htm and I

want
> it to show the IMAGES from MY counter ON NUMBER ONE!
>
> Now, the problem I´m having is that the counter INCREMENTS ITSELF when I
> open the page, BUT IT DOESN´T SHOW THE IMAGES...
>
> If I open HTTP://WWW.NUMBERONE.COM/COUNTER.PHP it shows all the images
> properly.
>
> Now, I´m a Newbie and I have no clue of what is going on here... Can

anyone
> help me???
>
> I don´t know if the problem is in my html file or in my php script...
>
> Help!!!
>
> BB
>
> <?php
> include ("parameters.inf");
> $vdigits = 1;
> if (file_exists("$datafile")) {
> $fp = fopen("$datafile", "r+");
> flock($fp, 2);
> $count = fgets($fp, 4096);
> $count += 1;
> fseek($fp,0);
> fwrite($fp, $count);
> flock($fp, 3);
> fclose($fp);
> } else {
> echo "Your Counter.dat file is missing '\$file' var...<BR>";
> exit;
> }
> $count=chop($count);
>
> $vdigits = max(strlen($count), $vdigits);
>
> $count = substr("0000000000".$count, -$vdigits);
>
> $varreglo = preg_split("//", $count);
>
> for($i = 0; $i <= $vdigits; $i++) {
> if ($varreglo[$i] != "") {
> echo "<IMG SRC=\"$imgdir$varreglo[$i].gif\" border=\"0\"
> alt=\"$varreglo[$i]\">";
> }
> }
> ?>
>
>



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:34 PM   #3
Markus Ernst
 
Markus Ernst's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

> > src="www.NUMBERONE.COM/hello.php"

try: src="http://www.NUMBERONE.COM/hello.php"

hth
--
Markus


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:34 PM   #4
Balbino Brito
 
Balbino Brito's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

Hello Markus.

No. That´s not the problem. In fact, when I checked the code on the html
page it WAS http://www.numberone.com/hello.php . I made a mistake when i
wrote down www.numberone.com in my example.

Any other ideas or clue?

Thanks in advance.


"Markus Ernst" <derernst@yahoo.com> escribió en el mensaje
news:3f0e64f8$1_5@news.bluewin.ch...
> > > src="www.NUMBERONE.COM/hello.php"

>
> try: src="http://www.NUMBERONE.COM/hello.php"
>
> hth
> --
> Markus
>
>



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:34 PM   #5
Barry B
 
Barry B's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...




"Balbino Brito" <nospam@please.com> wrote in message
news:bem36s$6o6e1$1@ID-197907.news.uni-berlin.de...
> Hello Markus.
>
> No. That´s not the problem. In fact, when I checked the code on the html
> page it WAS http://www.numberone.com/hello.php . I made a mistake when i
> wrote down www.numberone.com in my example.
>
> Any other ideas or clue?
>
> Thanks in advance.
>
>


On your pages on server number 2 make sure that the images are referenced as
in server number 1.
In other words :
The server page is still read as if its on number 1 and the images will be
read from number 1.


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:35 PM   #6
Markus Ernst
 
Markus Ernst's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

"Balbino Brito" <nospam@please.com> schrieb im Newsbeitrag
news:bem539$6pdd9$1@ID-197907.news.uni-berlin.de...
> Hi Barry
>
> The code in the html page is the following:
>
> <html>
> <head>
> <title>Untitled</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
>
> <body bgcolor="#FFFFFF" text="#000000">
> <p>&nbsp; </p>
> <script language="php" src="http://www.NUMBERONE.com/counter.php">

</script>
> <noscript>
> <p align="left"><a href="http://www.NUMBERONE.com"
> target="_top"><img src="http://www.NUMBERONE.COM/counter.php"
> alt="" border="0" /></a> </p>
> </noscript>
> </body>
> </html>
>


So you say the script is called from the Number 1 server and is successfully
executed on Number 2 (counter updates). Did you write the counter.php script
yourself? If not, I have 2 ideas what you could look after in the script:
- Maybe there are relative image references in the script?
- Maybe there are some restrictions about the URL of the page that calls the
script? This could have been implemented to prevent people to abuse the
script.

Good luck
--
Markus


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:35 PM   #7
Balbino Brito
 
Balbino Brito's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

Hello Markus.

Your answers are below.

> So you say the script is called from the Number 1 server and is

successfully
> executed on Number 2 (counter updates).


Yes, it does...

> Did you write the counter.php script yourself?


Of course not, I´m a newbie. I put my hands on PHP 3 days ago. I found this
script on hotscripts or somewhere and I´m modifying it so it can be used the
way i need it. Anyway I think is a simple script, although it showed me how
to do some really good stuff. I hope to learn a lot really soon.

If not, I have 2 ideas what you could look after in the script:
> - Maybe there are relative image references in the script?
> - Maybe there are some restrictions about the URL of the page that calls

the
> script? This could have been implemented to prevent people to abuse the
> script.


Now, in order to comment this part of your message, I tried changing
COMPLETELY the script to do just one thing: Now take a look at this and tell
me if you know why this is not working:

File counter.php installed on www.numberone.com
<?php
$result="<IMG SRC=";
$result .='"';
$result .="http://www.NUMBERONE.com/images/counter/1.gif";
$result .='">';

echo $result;
?>

File countertest.htm installed on www.numbertwo.com
<html>
<head>
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp; </p>
<script language="php" src="http://www.NUMBERONE.com/counter.php"> </script>
</body>
</html>

Now, when I call from my web browser http://www.NUMBERONE.COM/counter.php it
returns a nice little number 1 with a flag behind it. I mean, the .gif file.
I can see it...

Now, when I call from my web browser
http://www.NUMBERTWO.COM/countertest.htm it doesn´t show anything at all.

So there´s my problem. How can I send the correct text to the browser FROM
the php file called through SCRIPT in an HTML page.

At least now I know that the problem it´s not the script itself, it´s
something different.... I don´t know what it is....

Help me please!!!!

Thanks a lot in advance.

BB


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:35 PM   #8
Markus Ernst
 
Markus Ernst's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

Now it gets clearer:

> <?php
> $result="<IMG SRC=";
> $result .='"';
> $result .="http://www.NUMBERONE.com/images/counter/1.gif";
> $result .='">';
>
> echo $result;
> ?>


That looks all right though you could make it easier:
<?php echo '<IMG SRC="http://www.NUMBERONE.com/images/counter/1.gif">'; ?>

As I assume that the number is a variable it will actually look as follows
(let's call the variable $number):
<?php echo '<IMG SRC="http://www.NUMBERONE.com/images/counter/' . $number .
'.gif">'; ?>

But you have a problem here:

> File countertest.htm installed on www.numbertwo.com


File must be named "countertest.php", of course PHP must run on the second
server. You only need PHP for the include, so you could also use different
technologies as Server Side Include or ASP or whatever runs on server Nr. 2.

> <script language="php" src="http://www.NUMBERONE.com/counter.php">

</script>

This is the syntax for client side including like Javascript. As PHP is
executed at the server side you have to use the PHP include syntax:

<?php include("http://www.NUMBERONE.com/counter.php"); ?>

If you use another technology for the include as mentioned above of course
you will need to use the appropriate syntax.

I hope that puts some light on it.

Good luck
--
Markus


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:35 PM   #9
Balbino Brito
 
Balbino Brito's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

Hi Markus.

On other newsgroup someone told me to use in the html the following:

iframe src="http://www.NUMBERONE.COM/counter.php" FRAMEBORDER="YES"
WIDTH="140" HEIGHT="70"</iframe>

And it worked just fine....

Now, the question remains, why I can´t insert the code as an script, but as
an iframe i can.

> File must be named "countertest.php", of course PHP must run on the second
> server. You only need PHP for the include, so you could also use different
> technologies as Server Side Include or ASP or whatever runs on server Nr.

2.

I can´t install PHP on Numbertwo, because it´s a free server and they don´t
support it.

>
> > <script language="php" src="http://www.NUMBERONE.com/counter.php">

> </script>
>


Thanks a lot for your input...

Any other thoughts?

BB


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:35 PM   #10
Ron
 
Ron's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Help on php counter NEWBIE...

"Balbino Brito" <nospam@please.com> wrote in message
news:bel46e$644ae$1@ID-197907.news.uni-berlin.de...
> Hello Everyone.
>
> I´m trying to make a counter in my server BUT I would like to call it FROM
> ANOTHER SERVER.
>
> Let me explain this a little further:
>
> Suppose I have a PHP-IIS Server working properly with an script called
> counter.php. We´ll call this server NUMBER ONE
>
> I want to show the counter on an HTML page that is hosted ON ANOTHER

SERVER,
> not mine. (I can upload the html though). We´ll call this server NUMBER

TWO.
>
> Now, I created an html page called default.htm calling the script using:
>
> <p>
> <script language="JavaScript1.2" type="text/javascript"
> src="www.NUMBERONE.COM/counter.php"> </script>
> </p>
>
> And I stored the HTML file on the NUMBER TWO server.
>
> Now, I want to open the url http://WWW.NUMBERTWO.COM/default.htm and I

want
> it to show the IMAGES from MY counter ON NUMBER ONE!
>
> Now, the problem I´m having is that the counter INCREMENTS ITSELF when I
> open the page, BUT IT DOESN´T SHOW THE IMAGES...
>
> If I open HTTP://WWW.NUMBERONE.COM/COUNTER.PHP it shows all the images
> properly.
>
> Now, I´m a Newbie and I have no clue of what is going on here... Can

anyone
> help me???
>
> I don´t know if the problem is in my html file or in my php script...
>
> Help!!!
>
> BB
>
> <?php
> include ("parameters.inf");
> $vdigits = 1;
> if (file_exists("$datafile")) {
> $fp = fopen("$datafile", "r+");
> flock($fp, 2);
> $count = fgets($fp, 4096);
> $count += 1;
> fseek($fp,0);
> fwrite($fp, $count);
> flock($fp, 3);
> fclose($fp);
> } else {
> echo "Your Counter.dat file is missing '\$file' var...<BR>";
> exit;
> }
> $count=chop($count);
>
> $vdigits = max(strlen($count), $vdigits);
>
> $count = substr("0000000000".$count, -$vdigits);
>
> $varreglo = preg_split("//", $count);
>
> for($i = 0; $i <= $vdigits; $i++) {
> if ($varreglo[$i] != "") {
> echo "<IMG SRC=\"$imgdir$varreglo[$i].gif\" border=\"0\"
> alt=\"$varreglo[$i]\">";
> }
> }
> ?>
>

Hi BB.

Reading through the thread there appear to be a couple of conceptual errors
that have not been rectified from the outset.

First it is NOT POSSIBLE for a PHP script to be executed on a server other
than the one it is resident, it is executed as a function of the webserver
process.

Javascript on the other hand is executed in the user's browser and knows
nothing about the server it came from and ( generally) cannot be affected by
the server.

So if your PHP script is on server 1 that is where it is executed. What is
returned from the server is the output of the script. - slightly pedantic
but a necessary clarification

Your script, listed above, outputs a snippet of html and this contains a
reference to an image file. The address of image file will be treated as
relative to the base URL of the page in which it is contained. So if an html
page from server 2 contains a call to invoke a PHP script on server 1, the
script as it stands will be referring to a file on server 2 which does not
exist - hence the blank image on your page.

You can easily fix this if you can get at the PHP code.
I said that the images were relative to the server from which the html page
was served. The override to this is to use a fully qualified path for the
image file.

edit whatever it is that sets up $imgdir so that it includes the full server
address.
Say it is on www.server1.com in directory /counterimages

You need to set $imgdir to 'http://www.server1.com/counterimages/'

That should allow the browser to obtain the images it needs from the correct
location.

As for the comment about Javascript not being affected by the server it is
residing on, There is nothing to stop a PHP script outputting Javascript as
part of a page of html.

Your html page on SERVER2 - default html is loading the output of server 1
as if it were Javascript. In which case server 1 should not be sending html
it should be sending a text file containing javascript.!

Fortunately most browsers blunder through these sort of errors without
alerting anyone. .

HTH
Ron









 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , , ,




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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Counter Strike MADMAX Help And Cheats 32 04-23-2008 11:53 PM
Pure HTML Hit Counter Paul White HTML 3 07-01-2007 2:06 PM
Free Counter? Tinkerbell Ebay Technical Questions 2 05-30-2007 1:37 AM
counter help . spot516 Gaming Questions 2 11-04-2006 3:47 PM
Counter Strike Cam The Games 1 08-29-2006 1:27 AM


Featured Websites




All times are GMT +1. The time now is 12:39 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98