Simple script

Parsa44

New Member
Messages
232
Reaction score
0
Points
0
I am having problems with some simple scripts:

PHP:
<html>
<body>
<?php
$skill = $fletching;
if (empty($user)); { ?>
    Welcome to ParsaAkbaris calculator, Parsa Akbari ftw!
    <form action="runescapefletching.php" method="get">
    <input type="text" name="user" size="1">
    <input type="submit" value="Send">
<?php
}
else {
    $order = array( "Fletching",); 
    $user = $_POST['user']; 
    $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user");
    $get = explode("\n", $get);
    $i = 0;

    foreach ($order as $key => $value) {
        $value = strtolower($value);
        $temp = explode(",", $get[$i]);
        $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]);
        $stats[$value] = $temp;
        $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);";
        eval($eval);
        $i++;
    }
    if ($fletching[2] < 0){
    echo 'Your $skill is not on the hiscores, enter the amount of xp you have in $skill';
    ?>
    <form action="runescapefletching.php" method="get">
    The amount of xp:<input type="text" name="xp" size="1">
    Also your RuneScape username:<input type="text" name="user" size="1">
    <input type="submit" value="Send">
    <?php 
    }    
    else{ 
    echo ' <insert command here> ' ;
    }
    }
    ?>

    
</body>
</html>
 

nightscream

New Member
Messages
948
Reaction score
0
Points
0
I have found a few errors, maybe try this:

If(text) never ends with a ;
and if you delcare an array it ends with a ) not a ,) because if you put a , it will think you add another thing to the array.

PHP:
<html>
<body>
<?php
$skill = $fletching;
if (empty($user)) { ?>
    Welcome to ParsaAkbaris calculator, Parsa Akbari ftw!
    <form action="runescapefletching.php" method="get">
    <input type="text" name="user" size="1">
    <input type="submit" value="Send">
<?php
}
else {
    $order = array("Fletching"); 
    $user = $_POST['user']; 
    $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user");
    $get = explode("\n", $get);
    $i = 0;

    foreach ($order as $key => $value) {
        $value = strtolower($value);
        $temp = explode(",", $get[$i]);
        $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]);
        $stats[$value] = $temp;
        $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);";
        eval($eval);
        $i++;
    }
    if ($fletching[2] < 0){
    echo 'Your $skill is not on the hiscores, enter the amount of xp you have in $skill';
    ?>
    <form action="runescapefletching.php" method="get">
    The amount of xp:<input type="text" name="xp" size="1">
    Also your RuneScape username:<input type="text" name="user" size="1">
    <input type="submit" value="Send">
    <?php 
    }    
    else{ 
    echo ' <insert command here> ' ;
    }
    }
    ?>
    
</body>
</html>
 

Parsa44

New Member
Messages
232
Reaction score
0
Points
0
Thanks but there still seems to be a error on line 12
Ah right it seems to work thanks mate, can you tell me where my mistakes where?







Okay i made some edits to the script it still doesnt seem to work:


PHP:
<html>
<body>
<?php
$skill = 'fletching';
$user = $_GET['user'];
if (empty($user)) { echo'
    Welcome to ParsaAkbaris calculator, Parsa Akbari ftw!
    <form action="runescapefletching.php" method="get">
    <input type="text" name="user" size="17">
    <input type="submit" value="Send">';
}
else {
    $order = array("Fletching"); 
    $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user");
    $get = explode("\n", $get);
    $i = 0;

    foreach ($order as $key => $value) {
        $value = strtolower($value);
        $temp = explode(",", $get[$i]);
        $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]);
        $stats[$value] = $temp;
        $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);";
        eval($eval);
        $i++;
									   }
    if ($fletching[2] < 0){
    echo 'Your $skill is not on the hiscores, enter the amount of xp you have in $skill
    
    <form action="runescapefletching.php" method="get">
    The amount of xp:<input type="text" name="xp" size="1">
    Also your RuneScape username:<input type="text" name="user" size="1">
    <input type="submit" value="Send">';
						   }    
    else{ 
    echo ' <insert command here> ' ;
		}
	}
    ?>
    
</body>
</html>
 
Last edited:

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
Works for me, expect for some small errors:
Your $skill is not on the hiscores, enter the amount of xp you have in $skill
It's something I have answered before (in fact yesterday):
PHP doesn't look for variables inside ' and '. Fix:
(Either change ' to " or wrap variables into '. and .' )
 

Parsa44

New Member
Messages
232
Reaction score
0
Points
0
So i changed:

PHP:
$skill = 'fletching';

to

PHP:
$skill = "fletching";


but it still doesnt work for me.
 

nightscream

New Member
Messages
948
Reaction score
0
Points
0
Thanks but there still seems to be a error on line 12
Ah right it seems to work thanks mate, can you tell me where my mistakes where?
Those were your mistakes
if (empty($user)); {
$order = array("Fletching",);

what errors do you get now?
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
So i changed:

PHP:
$skill = 'fletching';
to

PHP:
$skill = "fletching";
but it still doesnt work for me.
no, he means make
PHP:
echo 'Your $skill is not on the hiscores, enter the amount of xp you have in $skill
    
    <form action="runescapefletching.php" method="get">
    The amount of xp:<input type="text" name="xp" size="1">
    Also your RuneScape username:<input type="text" name="user" size="1">
    <input type="submit" value="Send">';
to
PHP:
echo 'Your '.$skill.' is not on the hiscores, enter the amount of xp you have in '.$skill.'
    
    <form action="runescapefletching.php" method="get">
    The amount of xp:<input type="text" name="xp" size="1">
    Also your RuneScape username:<input type="text" name="user" size="1">
    <input type="submit" value="Send">';
 

Parsa44

New Member
Messages
232
Reaction score
0
Points
0
Those were your mistakes
if (empty($user)); {
$order = array("Fletching",);

what errors do you get now?

I would do that but what would i achieve? I am trying it to ASK for variable $user if it doesnt exist.
Edit:
Those were your mistakes
if (empty($user)); {
$order = array("Fletching",);

what errors do you get now?

I would do that but what would i achieve? I am trying it to ASK for variable $user if it doesnt exist.

Now what i try it it just comes up with a blank screen, which is rather annoying.
 
Last edited:

nightscream

New Member
Messages
948
Reaction score
0
Points
0
I would do that but what would i achieve? I am trying it to ASK for variable $user if it doesnt exist.
Edit:


I would do that but what would i achieve? I am trying it to ASK for variable $user if it doesnt exist.

Now what i try it it just comes up with a blank screen, which is rather annoying.
I thought you asked what you I editted.

what errors do you get now?
 

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
I would do that but what would i achieve? I am trying it to ASK for variable $user if it doesnt exist.
Edit:


I would do that but what would i achieve? I am trying it to ASK for variable $user if it doesnt exist.

Now what i try it it just comes up with a blank screen, which is rather annoying.

what you would achieve is that your variables would actually show up. PHP doesn't parse variables contained inside single-quotes ( ' ).
 

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
Those were your mistakes
if (empty($user)); {
$order = array("Fletching",);

what errors do you get now?
(bolded and underlined the parts)
*facepalm*

Parsa44, just do this:
no, he means make
PHP:
echo 'Your $skill is not on the hiscores, enter the amount of xp you have in $skill
    
    <form action="runescapefletching.php" method="get">
    The amount of xp:<input type="text" name="xp" size="1">
    Also your RuneScape username:<input type="text" name="user" size="1">
    <input type="submit" value="Send">';
to
PHP:
echo 'Your '.$skill.' is not on the hiscores, enter the amount of xp you have in '.$skill.'
    
    <form action="runescapefletching.php" method="get">
    The amount of xp:<input type="text" name="xp" size="1">
    Also your RuneScape username:<input type="text" name="user" size="1">
    <input type="submit" value="Send">';

to this code.
 
Top