1

i tried to set the value of the $_GET[] into an array object

this is my code

$X=array(
'status_1'=>'"'.$_GET['hasil_1'].'"',
'status_2'=>'"'.$_GET['hasil_2'].'"',
'status_3'=>'"'.$_GET['hasil_3'].'"',
.
.
'status_17'=>'"'.$_GET['hasil_17'].'"');

//Faktor Klasifikasi
$n = 'derajat';

//nama tabel
$table='tabel';

classify($X,$n,$table);

it's not working .

this is the url

http://localhost:8080/tugas/sispak/hasil.php?hasil_1=1&hasil_2=1&hasil_3=1&hasil_4=1&hasil_5=1&hasil_6=0&hasil_7=1&hasil_8=1&hasil_9=0&hasil_10=1&hasil_11=1&hasil_12=1&hasil_13=1&hasil_14=1&hasil_15=1&hasil_16=1&hasil_17=1

but , if i write it manualy like

$Y=array(
'status_1'=>'1',
'status_2'=>'1',
'status_3'=>'1',

.
.
'status_17'=>'1'
);

it works !!

this is where I handle the values of my array

//var_dump($allclass);
    foreach($allclass as $c=>$p)
    {
        foreach($X as $x=>$y)
        {
            $i = mysql_query("select count(*) as num from ".$table." where ".$n."='".$c."' AND ".$x."='".$y."'");
            $j = mysql_fetch_array($i,MYSQL_ASSOC);

            $P[$c][$x] = round($j["num"]/$allclass[$c],2);

    //Exception: P(data/class) might be 0 in some cases, ignore 0 for now
            if($P[$c][$x] != 0)
                $argmax[$c] *= $P[$c][$x];
        }
        $argmax[$c] *= $Pc[$c];
    }

somebody help me ,please

2
  • you're doing 'status_1' => '"foo"', with extra quotes. Commented Jun 2, 2015 at 18:26
  • "it's not working" Never think that this is an acceptable problem description. And if you'd just printed out your MySQL query you'd have seen the problem...... Commented Jun 2, 2015 at 18:41

1 Answer 1

4

You dont need all those quotes, try as follows:

$X = array(
    'status_1'=> $_GET['hasil_1'],
    'status_2'=> $_GET['hasil_2'],
    'status_3'=> $_GET['hasil_3']
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.