![]() |
|
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. |
| |||||||
| 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. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| 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]\">"; } } ?> | |||
|
| Advertisements |
| | #2 | ||
| 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]\">"; > } > } > ?> > > | |||
|
| | #4 | ||
| 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 > > | |||
|
| | #5 | ||
| "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. | |||
|
| | #6 | ||
| "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> </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 | |||
|
| | #7 | ||
| 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> </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 | |||
|
| | #8 | ||
| 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 | |||
|
| | #9 | ||
| 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 | |||
|
| | #10 | ||
| "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 | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: counter, help, newbie, php |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
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 | ||||
|