Jump to content

flOid

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Posts posted by flOid

  1. I'm trying to do a search and replace script in my vBulletin database after I did an import from IPB to clean some things up. here's the code:

     

    <?php
    
    $link = mysql_connect ("localhost", "###", "###");
    mysql_db_query("db", "UPDATE post SET pagetext = REPLACE(pagetext,"<!--QuoteBegin-","[quote]")", $link);
    mysql_db_query("db", "UPDATE post SET pagetext = REPLACE(pagetext,"</div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>QUOTE","")", $link);
    mysql_db_query("db", "UPDATE post SET pagetext = REPLACE(pagetext,"UPDATE post SET pagetext = REPLACE(pagetext,"</td></tr><tr><td id='QUOTE'>","")", $link);
    ?>

     

    the error I'm getting is

     

    "PHP Parse error:  syntax error, unexpected '-', expecting T_PAAMAYIM_NEKUDOTAYIM in searchreplace.php on line 4"

     

    What does that mean, and where is the error in my script?

     

     

  2. Sounds like a short open php tag problem - <?

     

    You need to change all <? to <?php and all <?= to <? echo

     

    The php.net recommendation for writing portable code -

     

    ; NOTE: Using short tags should be avoided when developing applications or

    ; libraries that are meant for redistribution, or deployment on PHP

    ; servers which are not under your control, because short tags may not

    ; be supported on the target server. For portable, redistributable code,

    ; be sure not to use short tags.

     

    Unfortunately, the short open tag allowed lazy programming and results in code that is not portable between servers with different settings.

     

    Yes, that was the problem, thanx a lot! :)

  3. is it showing the source code in the browser ?

     

    Yes, parts of it.

     

    But as I said, it's the same output as if I call the script that need to be included directly in the browser.

     

    Specifically source output is beginning with "member['var'];" which is part of the IPB internal class I mentioned before. It seems to be completely ignoring it now, before it was considered.

  4. PHP noob here...

     

    I recently upgraded my server to PHP5 and since then the PHP forum software (IPB 1.3.1., sec patched) I'm using isn't working any longer proberly.

     

    Using a modification for the software I was directly including PHP files from the board template.

     

    The files are still getting included, but now it isn't reading the IPB internal variables any longer. I was for example using the $ibforums->member[''] array (class?) before. Now it's just parsing the file as if I'm calling it directly in the browser.

     

    How can I fix this? Are there any setting in php.ini I can change to get this working?

  5. [!--quoteo(post=363812:date=Apr 11 2006, 04:49 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Apr 11 2006, 04:49 PM) [snapback]363812[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    Here is function I wrote a while back... It should help you with your problem.
    [code]<?php
    function time_diff($in_date)
    {
        $minute = 60;
        $hour = 60 * 60;
        $day = $hour * 24;
        $now = time();
        $start = strtotime($in_date);
        $seconds_left = $now - $start;
        $days_left = floor($seconds_left / $day);
        $hours_left = floor(($seconds_left % $day)/$hour);
        $minutes_left = floor((($seconds_left % $day) % $hour) / $minute);
        $seconds = $seconds_left - ($days_left * $day) - ($hours_left * $hour) - ($minutes_left * $minute);
        return (array($days_left,$hours_left,$minutes_left,$seconds));
    }

    echo '<pre>' . print_r(time_diff('2006-01-01'),true) . '</pre>';
    ?>[/code]

    Ken
    [/quote]

    Indeed that was very helpful! My script is working now, thanx a lot! :)
  6. [!--quoteo(post=363795:date=Apr 11 2006, 04:05 PM:name=Twentyoneth)--][div class=\'quotetop\']QUOTE(Twentyoneth @ Apr 11 2006, 04:05 PM) [snapback]363795[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    $totaltime = 360 (seconds)
    $hours = (($totaltime / 60) / 60);

    echo $hours;
    That should give you a decimal point number, like 0.something hours....that would be my best try :S
    [/quote]

    thanx, but that was not what I was looking for, I actually could have done that by myself. What I was looking for was not a decimal number but seperated values for total hours and minutes.
  7. I have written a small script which outputs the total number of seconds of a MP3 playlist stored in a database. But I would like to output total hours and minutes of the playlist like "the playlist has a running time of xx hours and xx minutes".

    I'm a PHP newbie and bad in maths, so could anyone provide me the needed algo?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.