Page 2 of 2 FirstFirst 12
Results 17 to 24 of 24

Thread: Undefined offset

  1. #17
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre
    This is not the same script but the same code is used in it!

    PHP Code:
    <?php

     
    include ("config.php");

     
    /* lets pull new information from the file and add it*/
    if(isset($update)) {
       echo
    "updating database...";
       
    /* check if the file contains data */
      
    if ( !$ranksTXT file_get_contents "ranks.txt" ) )
      {
        
    mysql_query("truncate table ranks");
        echo
    "Ranks table seems to be empty :(";
      }
     
     else
      {
       
    mysql_query("truncate table ranks");
        
    /* adding the data.. */
        
    $playersArray explode"\n"$ranksTXT);
        
    $arraysize sizeof($playersArray) -1;

        for ( 
    $i 0$i $arraysize$i++)
        {
        
    $playersArray[$i] = explode "\t"$playersArray[$i] );
        
    /* use str_replace so not to messup the database with nubs that have ' in their name :/ */
        
    $rank   trim($playersArray[$i][0]);
        
    $name   str_replace "'""\'"trim($playersArray[$i][1]) );
        
    $kills  trim($playersArray[$i][2]);
        
    $deaths  trim($playersArray[$i][3]);
        
    $score trim($playersArray[$i][4]);
        
    $mvp   trim($playersArray[$i][5]);
        
    $games  trim($playersArray[$i][6]);
        
    $gdi  trim($playersArray[$i][7]);
        
    $nod  trim($playersArray[$i][8]);

        
    mysql_query("INSERT INTO ranks(rank,name,kills,deaths,score,mvp,games, gdi, nod) VALUES('".$rank."','".$name."','".$kills."','".$deaths."','".$score."','".$mvp."','".$games."','".$gdi."','".$nod."')") or die(mysql_error());
       }
       
       echo
    "<meta http-equiv=Refresh content=1;url='?'>";
       }
       } 
    else { 
       
    /* all done lets view the new data */
      
    echo"<table class='tborder' cellpadding='6' cellspacing='1' width='100%'>

      <tr>
       <td class='thead'>Rank</td>
       <td class='thead' width='100%'>Name</td>
       <td class='thead'>Score</td>
       <td class='thead'>Kills</td>
       <td class='thead'>Deaths</td>
       <td class='thead'>GDI</td>
       <td class='thead'>Nod</td>
       <td class='thead'>Games</td>
     </tr>"
    ;
       
    /* spread the data over pages, say 50 results a page */
       
    if(!isset($_GET['pagecount'])){ 
        
    $pagecount 1
        } else { 
        
    $pagecount $_GET['pagecount']; 
        } 
        
    $max_results 50
        
    $from = (($pagecount $max_results) - $max_results); 

        
    $total_results mysql_result(mysql_query("SELECT COUNT(*) as Num FROM ranks"),0); 
        
    $total_pages ceil($total_results $max_results);
        
    $fetch mysql_query("SELECT * FROM `ranks` ORDER BY score DESC limit $from$max_results");
         while(
    $myrow mysql_fetch_object($fetch)) {
       
      echo
    "<tr>
      <td class='rank'>
    $myrow->rank</td>    
      <td class='name'>
    $myrow->name</td>    
      <td class='score'>
    $myrow->score</td>        
      <td class='kills'>
    $myrow->kills</td>
      <td class='deaths'>
    $myrow->deaths</td>
      <td class='gdi'>
    $myrow->gdi</td>
      <td class='nod'>
    $myrow->nod</td>
      <td class='games'>
    $myrow->games</td>    
      </tr>"
    ;   
      }
      }
      echo
    "</table><table class='links' cellpadding='6' cellspacing='1' width='100%'>";
      echo
    "<td class='thead'>";
      
    /* add the links to view all pages */
      
    if($pagecount 1){ 
        
    $prev = ($pagecount 1); 

        echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?pagecount=$prev\"><<Previous</a> &nbsp;"
        } for(
    $i 1$i <= $total_pages$i++){ 
        if((
    $pagecount) == $i){ 
        echo 
    "$i&nbsp;"
        } else { 
        echo 
    "<a href=\"".$_SERVER['PHP_SELF']."?pagecount=$i\">$i</a> &nbsp;"
        } 
       } 

      if(
    $page $total_pages){ 
        
    $next = ($pagecount 1); 
       } 
    ?>
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

  2. #18
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre

    Thumbs up

    You asked for more, here you go

    I'm using str_replace so sohw what mods are in game by making there name stand out, the easy way would be to code it direct in to the page like

    PHP Code:
         $playerinfo->name   str_replace "admin1""<b>%admin1</b>"$playerinfo->name );
         
    $playerinfo->name   str_replace "mod1""<b>%mod1</b>"$playerinfo->name );
         
    $playerinfo->name   str_replace "mod2""<b>%mod2</b>"$playerinfo->name ); 
    ect but thats alot of hassle to change every time i add a new mod ect


    I'd like to have it read a file like

    Code:
    /* admins */
    admin1
    admin2
    
    /* full mods */
    mod1
    mod2
    
    /* half mods */
    halfmod1
    halfmod2
    haldmod3
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

  3. #19
    cat /dev/null streetster's Avatar
    Join Date
    Jul 2003
    Location
    London
    Posts
    4,138
    Thanks
    119
    Thanked
    100 times in 82 posts
    • streetster's system
      • Motherboard:
      • Asus P7P55D-E
      • CPU:
      • Intel i5 750 2.67 @ 4.0Ghz
      • Memory:
      • 4GB Corsair XMS DDR3
      • Storage:
      • 2x1TB Drives [RAID0]
      • Graphics card(s):
      • 2xSapphire HD 4870 512MB CrossFireX
      • PSU:
      • Corsair HX520W
      • Case:
      • Coolermaster Black Widow
      • Operating System:
      • Windows 7 x64
      • Monitor(s):
      • DELL U2311
      • Internet:
      • Virgin 50Mb
    right... it seems like a way to do this would be to create 3 arrays (admins/fullmods/halfmods) from the input of a textfile...

    if the text file were

    Code:
    admin1
    admin2
    ~
    mod1
    mod2
    ~
    halfmod1
    halfmod2
    haldmod3
    ~

    you could do:

    $tempArray = explode( "~", $inputTXT);

    this would mean that
    $tempArray[0] is a list of all the admins
    $tempArray[1] is a list of all the full mods
    $tempArray[2] is a list of all the half mods

    these could then be exploded into
    $adminArray
    $fullmodArray
    $halfmodArray

    by exploding on the "\n" newline character

    it seems quite expensive to then iterate over the arrays to $name exists in there.. but maybe something like:

    for ($i = 0; $i < sizeof($tempArray[0]; $i++)
    {

    if($tempArray[$i] == $name)
    $name = str_replace ( "$name", "<b>$name</b>",
    }

    but i'm not sure how the 'fullmods' and 'halfmods' would be presented.. if you want to match 'modx_3' and change it to "<b>Blah Mod X version 3</b>" you could add some extra array such that

    if($mod_small_name[$i] == $name)
    $name = str_replace ( "$name", "$mod_full_name[$i]",
    }

    but you would have to change the textfile to be something like..

    Code:
    admin1
    admin2
    ~
    mod1, title goes here
    mod2, title goes here
    ~
    halfmod1, title goes here
    halfmod2, title goes here
    haldmod3, title goes here
    ~
    and do some more exploding around the "," character..

    An alternative would if you can use associative arrays in php (im not much of an expert), if so then you could simply do $name = myarray[$mod_small_name], where that entry is "Blah Mod X version 3".

    Does any of that make sense? I've got 2 exams on monday, but monday evening I might be able to have a bash at writing some php to do all that array business
    Last edited by streetster; 20-01-2007 at 07:40 PM.

  4. #20
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre
    No need for an array for each level, This should work but it only works if the name is at he bottom of the file

    PHP Code:
        $modfile file('mods.txt');
      
        foreach (
    $modfile as $line_num => $mod) {
        
    $playerinfo->name   str_replace $mod"<b>$mod</b>"$playerinfo->name );
        } 
    Last edited by Barry; 21-01-2007 at 02:02 AM.
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

  5. #21
    cat /dev/null streetster's Avatar
    Join Date
    Jul 2003
    Location
    London
    Posts
    4,138
    Thanks
    119
    Thanked
    100 times in 82 posts
    • streetster's system
      • Motherboard:
      • Asus P7P55D-E
      • CPU:
      • Intel i5 750 2.67 @ 4.0Ghz
      • Memory:
      • 4GB Corsair XMS DDR3
      • Storage:
      • 2x1TB Drives [RAID0]
      • Graphics card(s):
      • 2xSapphire HD 4870 512MB CrossFireX
      • PSU:
      • Corsair HX520W
      • Case:
      • Coolermaster Black Widow
      • Operating System:
      • Windows 7 x64
      • Monitor(s):
      • DELL U2311
      • Internet:
      • Virgin 50Mb
    try this... obviously you'll need to adapt it for you exact needs but it works for me

    modlist.txt :
    Code:
    admin1
    admin2
    admin3
    ~
    mod1, Modification X version 3
    mod2, Modification Y version 2
    mod3, Modification Z version 5
    ~
    halfmod1, Halfmod A version 2
    halfmod2, Halfmod B version 7
    halfmod3, Halfmod C version 3
    phpfile
    PHP Code:
    <?php

      
    /* first read in modlists.txt */

        
    if ( !$modlist file_get_contents "modlist.txt" ) )
        {
          echo 
    "something went wrong...";
        }

       else
        {

          
    $allthree explode"~"$modlist );

          
    $admins   explode"\n"$allthree[0] );
          
    $fullmods explode"\n"$allthree[1] );
          
    $halfmods explode"\n"$allthree[2] );

          
    /* add all admins to associative array */

          
    for ( $i 0$i sizeof($admins) -1$i++)    // remove trailing newline
          
    {
         
    $trimmed trim($admins[$i]);
         
    $adminsAA[$trimmed] = $trimmed;
          }

        
    /* add all fullmods to associative array */

          
    for ($i 0$i sizeof($fullmods); $i++)
          {
          
    $fullmods[$i] = explode",",$fullmods[$i] );
          }

        for (
    $i 1$i sizeof($fullmods) - 1$i++)    // remove leading newline
        
    {
        
    $trimmed trim($fullmods[$i][1]);
           
    $fullmodsAA[$fullmods[$i][0]] = $trimmed;
          }


          
    /* now add all halfmods to associative array */

          
    for ($i 1$i sizeof($halfmods); $i++)        // remove leading newline
          
    {
          
    $halfmods[$i] = explode",",$halfmods[$i] );
          }

        for (
    $i 1$i sizeof($halfmods); $i++)
        {
        
    $trimmed $halfmods[$i][1];
          
    $halfmodsAA[$halfmods[$i][0]] = $trimmed;
          }

      }


      if ( !
    $playerlistTXT file_get_contents "playerlist.txt" ) )
      {
        echo 
    "something went wrong...";
      }

     else
      {

       
    $playersArray explode"\n"$playerlistTXT);

       for ( 
    $i 0$i sizeof($playersArray); $i++)
        {
        
    $playersArray[$i] = explode "\t"$playersArray[$i] );

        
    $name   trim($playersArray[$i][0]);
        
    $team   trim($playersArray[$i][1]);
        
    $score  trim($playersArray[$i][2]);
        
    $kills  trim($playersArray[$i][3]);
        
    $deaths trim($playersArray[$i][4]);
        
    $ping   trim($playersArray[$i][5]);

        
    /* this will make any admins bolded */

        
    if(!$adminsAA[$name] == "")
                
    $name "<b> " $name " </b>";

        
    /* add the stuff you want to do with the modification stuff here

        ie

        if(!$fullmodsAA[$fullmod] == "")
            $fullmod = "<b> " . $fullmodsAA[$fullmod] . "</b>";


        if(!$halfmodsAA[$fullmod] == "")
            $halfmod = "<b> " . $halfmodsAA[$fullmod] . "</b>";

        */
        
    echo $name ", " $team ", " $score ", " $kills ", " $deaths ", " $ping "<br />";

        
    $query "INSERT INTO status (name, team, score, kills, deaths, ping) values ($name$team$score$kills$deaths$ping)";

        
    /* if (!mysql_query($query) */

        
    }
      }
    ?>

  6. #22
    You're god damn right Barry's Avatar
    Join Date
    Jul 2003
    Posts
    1,484
    Thanks
    70
    Thanked
    75 times in 59 posts
    • Barry's system
      • Motherboard:
      • Gigabyte Z270M-D3H
      • CPU:
      • Intel i7 7700
      • Memory:
      • 16GB (2x8GB) Avexir 2400
      • Storage:
      • Samsung 860 256GB SSD, Sandisk Ultra 3D 500GB, LG BR Writer
      • Graphics card(s):
      • Evga GeForce GTX Titan X 12GB
      • PSU:
      • Corsair RM750I
      • Case:
      • Fractal Design Focus G
      • Operating System:
      • Windows 10 Professional
      • Monitor(s):
      • 28" Acer UHD 4K2K
      • Internet:
      • Sky Fibre
    Code:
    admin1
    admin2
    admin3
    ~
    mod1, Modification X version 3
    mod2, Modification Y version 2
    mod3, Modification Z version 5
    ~
    halfmod1, Halfmod A version 2
    halfmod2, Halfmod B version 7
    halfmod3, Halfmod C version 3
    It's not modifications, its moderators, I had them separated because they use different symbols to show their status, IE admin = & full mod = % half mod = +
    Someone left a note on a piece of cake in the fridge that said, "Do not eat!". I ate the cake and left a note saying, "Yuck, who the hell eats paper ?

  7. #23
    cat /dev/null streetster's Avatar
    Join Date
    Jul 2003
    Location
    London
    Posts
    4,138
    Thanks
    119
    Thanked
    100 times in 82 posts
    • streetster's system
      • Motherboard:
      • Asus P7P55D-E
      • CPU:
      • Intel i5 750 2.67 @ 4.0Ghz
      • Memory:
      • 4GB Corsair XMS DDR3
      • Storage:
      • 2x1TB Drives [RAID0]
      • Graphics card(s):
      • 2xSapphire HD 4870 512MB CrossFireX
      • PSU:
      • Corsair HX520W
      • Case:
      • Coolermaster Black Widow
      • Operating System:
      • Windows 7 x64
      • Monitor(s):
      • DELL U2311
      • Internet:
      • Virgin 50Mb
    ah ok.. cant you split it into three arrays anyway, and if they are in adminarray[$name] change their name to "&" . $name, if they're in fullmodarray[$name] change to "%" . $name etc?

  8. #24
    Registered User
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked
    0 times in 0 posts
    • maren17's system
      • Motherboard:
      • ASUS
      • CPU:
      • P4
      • Memory:
      • 2 GB
      • Storage:
      • 3x 160 GB Seagate
      • Graphics card(s):
      • ATI Radeon
      • Monitor(s):
      • 19" TFT
      • Internet:
      • 16000

    Re: Undefined offset

    forget my question. here is no help for me. thx for noting
    Last edited by maren17; 30-09-2007 at 04:11 PM.

Page 2 of 2 FirstFirst 12

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need a file player with audio offset
    By Norky in forum Consumer Electronics
    Replies: 3
    Last Post: 11-04-2005, 11:38 AM
  2. VCore Voltage Offset
    By Taz in forum PC Hardware and Components
    Replies: 5
    Last Post: 10-02-2005, 06:00 PM
  3. ET and offset?
    By praetorian in forum Automotive
    Replies: 1
    Last Post: 18-11-2003, 04: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
  •