Results 1 to 15 of 15

Thread: [PHP] whats wrong with this.

  1. #1
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [PHP] whats wrong with this.

    new problem explained at last post!



    it worked like 10 mins ago now i changed one thing(i dont remember) and now it doesnt work.
    can you guys see a problem. please excuse my crappy standards / coding. im new to php and im just fooling around with it.

    PHP Code:
    <?
    $Seconds = '3600';
    $Minutes = ($Seconds / 60);
    $Hours = ($Minutes / 60);
    $Days = ($Hours / 24);
    $Time = "$Seconds Seconds";
    if ($Days >= 1){
    $RHours = $Hours % ($Days);
    $RMinutes = $Minutes % ($RHours);
    $RSeconds = $Seconds % ($RMinutes);
    $RDays = Floor($Days);
    $Time = "$RDays D, $RHours Hr, $RMinutes Min, $RSeconds Sec";
    }elseif ($Hours >= 1){
    $RMinutes = $Minutes % ($Hours);
    $RSeconds = $Seconds % ($RMinutes);
    $RHours = Floor($Hours);
    $Time = "$RHours Hours, $RMinutes Minutes $RSeconds Seconds";
    }elseif ($Minutes >= 1){
    $RSeconds = $Seconds %($Minutes);
    $Minutes = Floor($Minutes);
    $Time = "$Minutes Minutes, $RSeconds Seconds";
    }
    imagettftext($im,8.0,0,47,63,$black,$font,$Time);
    imagettftext($im,8.0,0,46,61,$white,$font,$Time);
    imagettftext($im,8.0,0,47,86,$black,$font,$OldB);
    imagettftext($im,8.0,0,46,84,$white,$font,$OldB);
    imagettftext($im,8.0,0,50,109,$black,$font,$OldC);
    imagettftext($im,8.0,0,49,107,$white,$font,$OldC);
    imagettftext($im,8.0,0,154,86,$black,$font,$OldE);
    imagettftext($im,8.0,0,153,84,$white,$font,$OldE);
    imagettftext($im,8.0,0,168,109,$black,$font,$OldLe);
    imagettftext($im,8.0,0,167,107,$white,$font,$OldLe);
    imagepng($im);
    destroyimage($im)
    ?>

  2. #2
    Join Date
    Jul 2007
    Posts
    1,055
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If you have the exact same window open where you type the script use ctrl + z to undo . Otherwise I don't know what language that is or any others besides Pascal .

  3. #3
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Checking it out...



    You left out quite a few variable declarations. $im, $black, $white, $font, $OldB, $OldC, $OldE, and $OldLe.

    And destroyimage doesn't seem to be a valid function.

  4. #4
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    its actually a problem with
    PHP Code:
    $Time "$Seconds Seconds";
    if (
    $Days >= 1){
    $RHours $Hours % ($Days);
    $RMinutes $Minutes % ($RHours);
    $RSeconds $Seconds % ($RMinutes);
    $RDays Floor($Days);
    $Time "$RDays D, $RHours Hr, $RMinutes Min, $RSeconds Sec";
    }elseif (
    $Hours >= 1){
    $RMinutes $Minutes % ($Hours);
    $RSeconds $Seconds % ($RMinutes);
    $RHours Floor($Hours);
    $Time "$RHours Hours, $RMinutes Minutes $RSeconds Seconds";
    }elseif (
    $Minutes >= 1){
    $RSeconds $Seconds %($Minutes);
    $Minutes Floor($Minutes);
    $Time "$Minutes Minutes, $RSeconds Seconds";

    its the elseif it has to be all the same variable its comparing. so i have figured it out. ive just encountered other problems.

    ps destroyimage is fine look on php.net lol

  5. #5
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Ah, sorry. Doesn't show up in my phpDesigner. And when I tried to compile it, it threw an error.

    And is there anything more in the script? You don't have $Days, $Hours, $Minutes, or $Seconds defined here.

  6. #6
    Join Date
    Nov 2007
    Location
    Australia
    Posts
    38
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    arent you meant to use dots in front of and behind variables in strings? like this:
    PHP Code:
    $Time ".$Seconds. Seconds";

    $Time ".$RDays. D, .$RHours. Hr, .$RMinutes. Min, .$RSeconds. Sec";

    $Time ".$RHours. Hours, .$RMinutes. Minutes .$RSeconds. Seconds";

    $Time ".$Minutes. Minutes, .$RSeconds. Seconds"
    etc.

    [edit] i just checked some of my scripts and yeah, the dots make the variables work in the strings.
    http://travo.freetzi.com/statsig.phpno click adds in sig please.

  7. #7
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    @ Travo,

    It should still work without the dots.

    The dots are for appending two strings together. When you use the double quotes to use a string, you'll be able to use both variables and normal text together, without problems.

    Edit: Canada, mind me asking what you're trying to do here? If you want to output the current date, just use PHP's date() function.

  8. #8
    Join Date
    Nov 2007
    Location
    Australia
    Posts
    38
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @ jason2gs

    Ok. umm.... damn this is frustrating.

    i just realised you declared seconds as a string. you cant do math functions on a string.

    edit: @jason2gs again. it looks like a stat sig or somethin
    http://travo.freetzi.com/statsig.phpno click adds in sig please.

  9. #9
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,914
    Mentioned
    12 Post(s)
    Quoted
    98 Post(s)

    Default

    Oh my. Looks like CanadaMan just

    EPIC FAILED!
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  10. #10
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    haha hee hee. works now. ill post the code. thats was my first...no second attempt at it php so give me a break.
    @travo: actually you can do math functions on a string as php variables are variants (pretty sure, i maybe totally in left field though )
    yes it is a stat sig.

    PHP Code:
        $hours = ($minutes/60);
        
    $days = ($hours/24);
        
    $weeks = ($days/7);
         
    $months = ($weeks/4);
        
    $years = ($months/12);
    if (
    $minutes 525948){
        
    $rmonths = ($months $years);
        
    $rweeks = ($weeks $months);
        
    $rhours = ($hours $days);
        
    $rminutes = ($minutes $hours);
        
    $rdays = ($days $weeks);
        
    $ryears floor($years);
        
    $Time "$ryears Yr, $rmonths Mo, $rweeks Wk, $rdays D, $rhours H, $rminutes M";
    }elseif (
    $minutes 43829){
        
    $rweeks = ($weeks $months);
        
    $rhours = ($hours $days);
        
    $rminutes = ($minutes $hours);
        
    $rdays = ($days $weeks);
        
    $rmonths floor($months);
        
    $Time "$rmonths Mths, $rweeks Wks, $rdays Ds, $rhours Hs, $rminutes Ms";
    }elseif (
    $minutes 10080){
        
    $rhours = ($hours $days);
        
    $rminutes = ($minutes $hours);
        
    $rdays = ($days $weeks);
        
    $rweeks floor($weeks);
        
    $Time "$rweeks Weeks, $rdays Days, $rhours Hours, $rminutes Mins";
    }elseif (
    $minutes 1440){
        
    $rhours = ($hours $days);
            
    $rminutes = ($minutes $hours);
        
    $rdays floor($days);
        
    $Time "$rdays Days, $rhours Hours, $rminutes Minutes";
    }elseif (
    $minutes 60){
        
    $rminutes = ($minutes $hours);
        
    $rhours floor($hours);
        
    $Time "$rhours Hours, $rminutes Minutes";
    }elseif (
    $minutes 0){
        
    $Time "$minutes Minutes";
    }elseif (
    $minutes == 0){
            
    $Time '0 Minutes';

    the dots dont make a difference...actually it just outputs the dots as dots.

  11. #11
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Wait, so what was the problem with it?

  12. #12
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    you see in the first one how i did elseif(minutes) then next time i did elseif(hours) it was a comparison issue i guess.

  13. #13
    Join Date
    Dec 2006
    Location
    Third rock from the sun.
    Posts
    2,510
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Ah, alright

  14. #14
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    right now its working pretty good.

  15. #15
    Join Date
    Oct 2006
    Location
    Ontario,Canada
    Posts
    1,718
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok need some help here. some weird thing. explained below.
    PHP Code:
    if ($minutes 1440){
    $rdays floor($days);
    $rhours $hours % ($rdays*24);
    if (
    $rhours 0){
    $rminutes $minutes % ($rhours 60);
    }else{
    $rminutes $minutes % ($rdays*1440);
    }
    $Time "$rdays Days, $rhours Hours, $rminutes Minutes"
    after 1 day, 4 hours and 59 minutes it will go 1 day, 5 hours and 240 mins. i dont know why.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Whats Wrong.
    By kooldude in forum OSR Help
    Replies: 2
    Last Post: 03-27-2008, 09:13 AM
  2. Whats Wrong???
    By bilbobaggins in forum OSR Help
    Replies: 12
    Last Post: 04-10-2007, 10:05 AM
  3. Replies: 8
    Last Post: 03-23-2007, 04:20 PM
  4. Can someone tell me whats wrong with this?
    By Hey321 in forum OSR Help
    Replies: 5
    Last Post: 12-17-2006, 09:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •