Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    0
    ReputationRep:
    This is one of those annoying little ones that I can't seem to find any info on out there on t'Internet...

    Have got some code to, depending on the seconds past the minute display a different webcam image. It works fine on my test server, but once I upload it to the actual server it's not working.

    I realise it's probably not the best code and may not follow any layout standards...

    PHP Code:
    <?php
        $the_seconds 
    date('s'); // Also tried 'intval()' and 'floatval()
        
    $seconds_down round($the_seconds, -1PHP_ROUND_HALF_DOWN);
            
        if (
    $seconds_down == 10) { $cam "webcam-1.jpg?_=".time(); }
        if (
    $seconds_down == 20) { $cam "webcam-2.jpg?_=".time(); }
        if (
    $seconds_down == 30) { $cam "webcam-3.jpg?_=".time(); }
        if (
    $seconds_down == 40) { $cam "webcam-1.jpg?_=".time(); }
        if (
    $seconds_down == 50) { $cam "webcam-2.jpg?_=".time(); }
        if (
    $seconds_down == 60) { $cam "webcam-3.jpg?_=".time(); } // Rounds up to 60...
        
    if ($seconds_down == 0)  { $cam "webcam-3.jpg?_=".time(); } // ... and down to 0
            
        
    echo $the_seconds;    // Correctly displays the number of seconds
        
    echo $seconds_down;    // Shows the number of seconds on test server but not real server
    ?>
    The only thing I can possibly think of is something to do with PHP versions; the server is currently on 5.2.17 and the test server 5.3.10 (though I have requested the server is updated, BH weekend and all that!), but for something as simple as rounding I can't see that being the issue.

    Any help at all?
    Offline

    9
    ReputationRep:
    Look at the php documentation:
    http://php.net/manual/en/function.round.php

    The change log states that the "mode" parameter (which you are using) was only introduced in 5.3, and since your live server is 5.2 it will throw an error (actually it's a warning, PHP is too badass to make any logical sense) because you are providing more parameters than it's expecting. You can either upgrade your live server to a more recent version (5.3 introduced a lot of new stuff, so not a bad idea) or just get rid of the PHP_ROUND_HALF_DOWN parameter from your call to the round() function.
    • Thread Starter
    Offline

    0
    ReputationRep:
    Brilliant, thanks very much! The PHP_ROUND_HALF_DOWN paramater was only in there to see if it always rounded down to the nearest 10. I guess that's what happens when you try and code with no caffeine or nicotine in you... thanks for your help, sorry it was over such a silly thing really...
 
 
 
Poll
Do you agree with the PM's proposal to cut tuition fees for some courses?
Useful resources

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.