Notice
Like RMID on Facebook!
Follow RMID on Twitter @RPGMakerID

Share | 
 

 [Help!] Masalah dengan PHP

View previous topic View next topic Go down 
Sun 9 Oct 2011 - 8:11
Post[Help!] Masalah dengan PHP
#1
LowlingLife 
Global Moderator
Global Moderator


Level 5
Post Count: 1296
Joined: 2011-06-28
Thanked: 21
Engine: Multi-Engine User
Awards:

Jadi gini.... Kan aku mau bikin word generator berdasarkan kode yang diberikan oleh Seventh Sanctum... Nah, aku tuh udah bikin listnya banyak banget.. Kan kalo di seventh sanctum ada pilihan berapa banyak kata yang akan di generate atau Number to Generate.... Kan aku udah kasih pilihan 1-25... Tapi tetap aja yang keluar cuma 1 kata. Mestinya kan kalo dipilih 10
maka akan keluar 10 kata..... Generatornya itu kayak aneh... Jadi nge-reset ke 1 setiap dipilih... Kayaknya ada masalah sama variable nya...

Nih kodenya :
Spoiler:
 

Nih screenshotnya yang aku kira itu problemnya


Note : Perlu diingat bahwa kejadian yang nge-reset ke 1 itu tetap berlanjut walaupun sudah di-upload ke website....

Itu kodenya masih pure, belum diapa-apain...

______________________
Training to be :
A Reviewer
A Writer
A Journalist

Epic Quote :
[20:04:54] @ TheoAllen : jarang2 ada member yg nasionalis RMID bgt :hammer:



Thread That I Support :


All of my script are made under this license


Cause Ngacay can bring inspiration & makes you healthy!

Join Ngacay Club!
Reply to topic
Sun 9 Oct 2011 - 13:17
PostRe: [Help!] Masalah dengan PHP
#2
nasgor 
Senior RMer D
Senior RMer D


Level 5
Post Count: 706
Joined: 2010-09-29
Thanked: 3
Engine: RM2k3
Skill: Skilled
Type: Writer

:shocked:
Code:
 $strLine=fgets($objData,1024);
  if (strlen($strLine)>1)
  {
      if (strlen(strrpos($strLine,"\n"))>0)
      {
        $strLine=substr($strLine,0,strlen($strLine)-2);
      }
  }

disinilah masalahnya.. harusnya
Code:
 $strLine0=fgets($objData,1024);
  if (strlen($strLine0)>1)
  {
      if (strlen(strrpos($strLine0,"\n"))>0)
      {
        $strLine .= substr($strLine0,0,strlen($strLine0)-2);
      }
  }

$strLine .= substr($strLine,0,strlen($strLine)-2);

padahal km bisa pake
Code:
$f=file('target.dat');
foreach($f as $v) $strLine.=$v;


jgn lupa gabung di http://www.facebook.com/groups/262652623756604/
Reply to topic
Mon 10 Oct 2011 - 17:48
PostRe: [Help!] Masalah dengan PHP
#3
LowlingLife 
Global Moderator
Global Moderator


Level 5
Post Count: 1296
Joined: 2011-06-28
Thanked: 21
Engine: Multi-Engine User
Awards:

Om, itu maksudnya harus di-replace om?

______________________
Training to be :
A Reviewer
A Writer
A Journalist

Epic Quote :
[20:04:54] @ TheoAllen : jarang2 ada member yg nasionalis RMID bgt :hammer:



Thread That I Support :


All of my script are made under this license


Cause Ngacay can bring inspiration & makes you healthy!

Join Ngacay Club!
Reply to topic
Wed 12 Oct 2011 - 10:15
PostRe: [Help!] Masalah dengan PHP
#4
nasgor 
Senior RMer D
Senior RMer D


Level 5
Post Count: 706
Joined: 2010-09-29
Thanked: 3
Engine: RM2k3
Skill: Skilled
Type: Writer

iya donk..
ada pertanyaan lagi?
Reply to topic
Fri 14 Oct 2011 - 16:41
PostRe: [Help!] Masalah dengan PHP
#5
LowlingLife 
Global Moderator
Global Moderator


Level 5
Post Count: 1296
Joined: 2011-06-28
Thanked: 21
Engine: Multi-Engine User
Awards:

Wah, om... Yang di replace itu $strLine .= substr($strLine,0,strlen($strLine)-2); -> $f=file('target.dat');
foreach($f as $v) $strLine.=$v; doang atau $strLine=fgets($objData,1024);
if (strlen($strLine)>1)
{
if (strlen(strrpos($strLine,"\n"))>0)
{
$strLine=substr($strLine,0,strlen($strLine)-2);
}
} -> $f=file('target.dat');
foreach($f as $v) $strLine.=$v; ? Karena saya coba gak bisa....

______________________
Training to be :
A Reviewer
A Writer
A Journalist

Epic Quote :
[20:04:54] @ TheoAllen : jarang2 ada member yg nasionalis RMID bgt :hammer:



Thread That I Support :


All of my script are made under this license


Cause Ngacay can bring inspiration & makes you healthy!

Join Ngacay Club!
Reply to topic
Sat 22 Oct 2011 - 18:27
PostRe: [Help!] Masalah dengan PHP
#6
nasgor 
Senior RMer D
Senior RMer D


Level 5
Post Count: 706
Joined: 2010-09-29
Thanked: 3
Engine: RM2k3
Skill: Skilled
Type: Writer

ternyata problemnya bukan 1 tp banyak.. bahkan gw sampe harus bikin ulang
Code:
<html>
<HEAD>
<TITLE>
Basic Word Generator
</TITLE>
</HEAD>
<body>
<CENTER>
<B>
<FONT SIZE=5>Basic Word Generator</FONT>
</B>
</CENTER>
<?php
$selGenCount =$_POST[selGenCount];
//Initialize
srand((double)microtime()*1000000);

if ($selGenCount < 1)
{
  $selGenCount=1;
}

//Data setup
$strWords = array();
$intWordCode = array();
$intFetchCode = array();
$strFetchText = array();

$ar=file("filedat.dat") or die("File could not be opened.");
foreach($ar as $f)
{
   $strLine=trim($f);
   if($strLine=="\n") continue;
   if ($strLine=="//") continue;
   
   if ($strLine=="--ORGANIZATION")
   {
      $intState=1;      continue;
   }
   if ($strLine=="--VOCABULARY")
   {
     $intState=2; continue;
   }
   
   
   switch($intState)
    {
            case 0:
              //Nothing
              break;
            case 1:
              if ($bOrgLevel==true)
              {
                  $strFetchText[ ] = explode(",",$strLine);
                  $bOrgLevel=false;
              }
              else
              {
                  $intFetchCode[ ] = explode(",",$strLine);
                  $bOrgLevel=true;
              }
              break;
            case 2:
              if (strlen(strpos($strLine,","))>0)
              {
                  $strHolder=strtolower(chop(trim(substr($strLine, (strpos($strLine,",")+1), strlen($strLine)))));
                  $bTrump=($strHolder=="true");
                  $strLine=chop(trim(substr($strLine, 0, (strpos($strLine,",")))));
                  $strWords[ ] = $strLine;
                  $intWordCode[ ] = intval($strHolder);
              }
              else
              {
                  $strWords[ ] = $strLine;
                  $intWordCode[ ] = 0;                 
              }
              break;
    }

}
 

fclose($objData);

//print_r($strWords);
?>
<HR>
<form action="?f=12" method="POST" name="frmControls">
    <p>Number to Generate: <select name="selGenCount" size="1">
<?php
  if ($selGenCount==1)
  {
      print("<option value=1 selected>1</option>");
  }
  else
  {
      print("<option value=1>1</option>");
  }

  for ($intLooper=5;$intLooper<55;$intLooper+=5)
  {
      if ($selGenCount==$intLooper)
      {
        print("<option value=$intLooper selected>$intLooper</option>");
      }
      else
      {
        print("<option value=$intLooper>$intLooper</option>");
      }
  }

?>
    </select>
  <input type="submit" name="subGenerate" value="Generate"></p>
</form>
<HR><?php

  function GetWord($intNeedGet,$intAlreadyHave)
  {
      global $intWordCode;
     
      $bStop = false;
     
      do
      {
        if (count($intWordCode)==1)
        {
            $intReturnNumber=0;
        }
        else
        {
            $intReturnNumber=rand(0,count($intWordCode)-1);
        }

        $bStop=true;

        if (($intWordCode[$intReturnNumber] & $intNeedGet)!=$intNeedGet)
        {
            $bStop=false;
        }

        for ($intLooper=0;$intLooper<count($intAlreadyHave);$intLooper++)
        {
            if ($intReturnNumber==$intAlreadyHave[$intLooper])
            {
              $bStop=false;
            }
        }

      }
      while ($bStop==false);

      return($intReturnNumber);
    
  }

  function GenTerm()
  {
      //Get access to the fetch array.
      global $intFetchCode;
      global $strFetchText;
            global $strWords;

      settype($strTerm, "string");

      $intLooper=0;
      //Only a 25% chance of a title

      if ((count($intFetchCode)-1)==0)
      {
              $intWhichFetch = 0;
      }
      else
      {
              $intWhichFetch = rand(0,count($intFetchCode)-1);
      }

      $intArrayHold=array();

      for ($intLooper = 0 ; $intLooper < count($intFetchCode[$intWhichFetch]) ; $intLooper++)
      {
        $intArrayHold[$intLooper]=-1;
      } 

      for ($intLooper = 0 ; $intLooper < count($intFetchCode[$intWhichFetch]) ; $intLooper++)
      {
        $intArrayHold[$intLooper]=GetWord($intFetchCode[$intWhichFetch][$intLooper], $intArrayHold);
      }

      $strTerm=$strFetchText[$intWhichFetch][0];

      for ($intLooper = 0 ; $intLooper < count($intFetchCode[$intWhichFetch]) ; $intLooper++)
      {
        $strTerm .=" ". $strWords[$intArrayHold[$intLooper]];
        $strTerm .=" ". $strFetchText[$intWhichFetch][$intLooper+1];
      }

      return($strTerm);
  }



  if(intval($selGenCount) == 1)
  {
      print("<B>Creation:</B><BR>");
  }
  else
  {
      print("<B>Creations:</B>  <BR>");
  }

  $aGenHold=array();

  for ($intLooper=0;$intLooper<$selGenCount;$intLooper++)
  {
      $aGenHold[$intLooper]=GenTerm();
    
  }

  sort($aGenHold);

  for ($intLooper=0;$intLooper<$selGenCount;$intLooper++)
  {
      print($aGenHold[$intLooper]);
      print("<BR>");
  }

?>
<HR>
</body>
</html>

dari masalah baca file hingga terakhir masalah dia gk pake

$selGenCount =$_POST[selGenCount];
Reply to topic
 

[Help!] Masalah dengan PHP

View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
RPGMakerID :: Non-RM :: Computer and Software-