FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Problems with a script..





Diablosblizz
Okay, I got a code from somebody off this forums, and it worked for the most part.. but when I put it into a marquee then it doesn't say anything. Heres the code:

Code:
<?php
error_reporting(0);
function pingDomain($domain){
    $starttime = microtime(true);
    $file      = fsockopen ($domain, 8000, $errno, $errstr, 1); // 90 = port, 5 = times
    $stoptime = microtime(true);
    $status    = 0;

    if (!$file) $status = -1;  // Site is down
    else {
        fclose($file);
        $status = ($stoptime - $starttime) * 1000;
        $status = floor($status);
    }
    return $status;
}

$status = pingDomain("IP BLOCKED OFF HERE"); // Change to your IP
if($status != -1) {
   echo "<font color='green'>Online</font>";
   }else{
   echo "Offline";   
}
?>


It doesn't say anything, it just marquees everything but that php script. Also note that the script works on a normal page, but when its included in a page, it doesn't work.
MrBlueSky
What's the code you include it in? Because this

Code:

<?php

  include("ping.php");
 
?>


works. (When your script above is named ping.php)
Diablosblizz
Okay, I included the code (in the marquee file) and it still does not work in a include (on my main page)
MrBlueSky
No, I meant can you post the code of the file in which you include the ping script? Very Happy
Diablosblizz
All this code does it tells if the script can connect to the IP and PORT. And if it does it gives a message, and if not, a different message. If you want my marquee.php then:

Code:
<style type="text/css">
.text   {font-size: 10px;
         font-family: Verdana, Arial, Helvetica, sans-serif;
}
</style>
<body>
<span class="text">
<marquee><font color="green">This Weeks Rare:</font> None | <font color="green">This Weeks Comp:</font> None | <font color="green">This Weeks Poll:</font> Should Hotel Mario Have a Radio? <a href="poll.php" target="content">Vote!</a> | Radio Server: <?php include('radiostat.php'); ?>
</marquee>

**THATS INCLUDING THE CODE THAT I POSTED BEFORE IN A DIFFERENT FILE**

This, is the code with the code posted above in it:
Code:
<style type="text/css">
.text   {font-size: 10px;
         font-family: Verdana, Arial, Helvetica, sans-serif;
}
</style>
<body>
<span class="text">
<marquee><font color="green">This Weeks Rare:</font> None | <font color="green">This Weeks Comp:</font> None | <font color="green">This Weeks Poll:</font> Should Hotel Mario Have a Radio? <a href="poll.php" target="content">Vote!</a> | Radio Server: <?php
error_reporting(0);
function pingDomain($domain){
    $starttime = microtime(true);
    $file      = fsockopen ($domain, 8000, $errno, $errstr, 1); // 90 = port, 5 = times
    $stoptime = microtime(true);
    $status    = 0;

    if (!$file) $status = -1;  // Site is down
    else {
        fclose($file);
        $status = ($stoptime - $starttime) * 1000;
        $status = floor($status);
    }
    return $status;
}

$status = pingDomain("BL0000000CCCCKKKKK33333DDDDDD"); // Change to your IP
if($status != -1) {
   echo "<font color='green'>Online</font>";
   }else{
   echo "Offline";   
}
?>

</marquee>



Sorry, if I got something wrong, I'm not 100% sure of what your asking.
MrBlueSky
Strange. It works when I put the code on my computer.

Look at the source code of the 'empty' page and see what it actually outputs. Maybe that gives a hint about what is wrong.
MrBlueSky
-- edit --

Click here: http://www.mrbluesky.frih.net/test/test.php

If you don't see anything the problem is with your browser. Remember that <marquee> not is valid HTML and not all browsers support it.
Diablosblizz
Your not understanding. Yes I can see that the script works.. now.. on any other page.. with codes on it.. then use PHP include to include the test file.
MrBlueSky
You mean like this?

Code:

<style type="text/css">
.text   {font-size: 10px;
         font-family: Verdana, Arial, Helvetica, sans-serif;
}
</style>
<body>
<span class="text">
<marquee><font color="green">This Weeks Rare:</font> None | <font color="green">This Weeks Comp:</font> None | <font color="green">This Weeks Poll:</font> Should Hotel Mario Have a Radio? <a href="poll.php" target="content">Vote!</a> | Radio Server: <?php include('ping.php'); ?>
</marquee>
Diablosblizz
Yes, but if you want an example then:

http://hotelmario.net.tc/test.php (WAIT TILL END)


don't worry about the nav.. it sucks for now but its a test.. Look at the marquee scrolling at the top.. it doesn't show the Radio Server: ...

But, if you go to

http://hotelmario.net.tc/marquee.php (WAIT TILL END)


Now it shows it.. if I remove my content on the test.php and only leave the image and the marquee, then it works..


Any ideas?



EDIT: If I remove the other code... then it works.. Sad this is so hard to figuer out..
MrBlueSky
Sorry, it took a while but now I understand the problem.

Diablosblizz wrote:



Any ideas?


Replace

Code:

error_reporting(0);


by

Code:

error_reporting(E_ALL);


in your php-files to see if an error or warning shows up.
Diablosblizz
Quote:
Fatal error: Cannot redeclare pingdomain() (previously declared in /home/mario/public_html/marioon.php:3) in /home/mario/public_html/marquee.php on line 10


This I guess means that its already called in the same page.. how can I fix it?
MrBlueSky
Use

Code:

include_once("something.php");


instead of

Code:

include("something.php");


everywhere in your code
Diablosblizz
Same problem, Just to let you know, that I do have two of the same codes on the same page, just a different port.
MrBlueSky
Diablosblizz wrote:
Same problem, Just to let you know, that I do have two of the same codes on the same page, just a different port.


Ah, oke. Rename one of them.

-- edit--

I mean: rename one of the functions
Diablosblizz
They're not in the same file.. they're in two different files but they are the same script but a different port.
MrBlueSky
Diablosblizz wrote:
They're not in the same file.. they're in two different files but they are the same script but a different port.


You can't include 2 different files in one page if both files have a function with the same name, so you have to rename one of the functions.
MrBlueSky
Have you fixed it? If not, feel free to zip your files and send them to me, then I will (try to) fix it for you.
Diablosblizz
I can't fix it I don't know how, for now its not a big issue.
taitj
Anyone know of any good free poll or voting scripts either in flash or php? I would like one that you can manage from an admin panel so that I can remotely manage the polls.

Thanks,
Related topics
problems
I can't upload my Database SQL script ! Helllppppp!!!!
Script to automatically restart Apache (for server 1)
Flash script problem
Script execution problem
my PHP code benchmark script that got some problems
Cheapist mmorpg script
Problems with a Guess a Number Code.
Problems with php + mysql script.
Wanting a PHP input security script: up to 1200frih$!
problems with mail()
problems withs script
Uploading an Image using PHP script - RESOLVED
Problem with galary script
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.