Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

PHP Game Script


ghost's Avatar
0 0

Hello, I am working on a game and I have a few error :(

Note: I always have errors…

<?php
require_once "../htmlbegin.php";
include "../config.php";
if (isset($_SESSION['setuser']))
{
?>
<?php
$result = mysql_query("SELECT * FROM `users` WHERE user_id=".$_SESSION['setid']."");
$row = mysql_fetch_array($result);
if (!$result) 
{
    die('Invalid query: ' . mysql_error());
}

if (($row['new']=="yes"))
{

?>
<center>
<b>
<h2>Configuration Form</h2>
<form name='config' id='config' method='post'>
[Set IP]
<input name='ip' id='ip' type='textbox' class='textbox'>
<hr />
[Set IP.ID]
<input name='ip_id' id='ip_id' type='textbox' class='textbox'>
<hr />
[Set Router IP] 
<input name='router_ip' id='route_ip' type='textbox' class='textbox'>
<hr />
[Set Router ID]
<input name='router_id' id='route_id' type='textbox' class='textbox'>
<hr />
<input name='submit' id='submit' type='submit' class='submit' value='[SET]'>
</b>

<?php
if ($_POST['submit'])
{
$ip=stripslashes($_POST['ip']);
$ip_id=stripslashes($_POST['ip_id']);
$router_ip=stripslashes($_POST['router_ip']);
$router_id=stripslashes($_POST['router_id']);
mysql_real_escape_string($ip);
mysql_real_escape_string($ip_id);
mysql_real_escape_string($router_ip);
mysql_real_escape_string($router_id);
$ip_test = mysql_query("SELECT * FROM ip_info WHERE ip='$ip'")
or die ('Error: ' . mysql_error());
if ($row = mysql_fetch_array($ip_test))
{
echo 'This IP is already in use!';
}

$ip_id_test = mysql_query("SELECT * FROM ip_info WHERE ip_id='$ip_id'")
or die ('Error: ' . mysql_error());
if ($row = mysql_fetch_array($ip_id_test))
{
echo 'This ID is in use!';
}

}
else
{
$sql = "INSERT INTO ip_info(`ip`, `ip_id`, `router_ip`, `router_id`) VALUES ('{$_POST['ip']}', '{$_POST['ip_id']}', '{$_POST['router_ip']}', '{$_POST['router_id']}')";
mysql_query($sql)
or die('Error: ' . mysql_error());
echo 'Configuration Successful!;
}

}
else
{
echo ' ';
}
?>


<?php
}
else
{
echo "Refresh Script";
}

}
else
{
echo "Refresh Script";
}

require_once "../htmlend.php";
?>

What I was trying to do with it is fairly obvious, I do not understand why it is not working. If I remove the PHP in the middle it works…

This is the error I am getting: Parse error: syntax error, unexpected ''', expecting ',' or ';' in /home/www/zbit.awardspace.com/alpha/game/config.new.php on line 75


ghost's Avatar
0 0

masta_hacks wrote: VALUES ('{$_POST['ip']}', '{$_POST['ip_id']}', '{$_POST['router_ip']}', '{$_POST['router_id']}')";

What in the bloody hell is that?

What I was trying to do with it is fairly obvious, I do not understand why it is not working.

Well, for a while, it was SOMEWHAT obvious… but, that just threw it all out of whack. I'd start looking at the line above.


spyware's Avatar
Banned
0 0

PHP errors = PHP fixes.

If not: world collapses.


ghost's Avatar
0 0

Hmm, I did't make that so I am not sure lol


ghost's Avatar
0 0

masta_hacks wrote: Hmm, I did make that so I am not sure lol

Umm… you mind rephrasing that for people that don't speak stupid?


ghost's Avatar
0 0

It has to be that way or it does not work at all…


ghost's Avatar
0 0

masta_hacks wrote: It has to be that way or it does not work at all…

Obviously, it doesn't have to be that way, since it doesn't work, regardless.


ghost's Avatar
0 0

I ment that line.


korg's Avatar
Admin from hell
0 0

Look at your error! it's really right in your face!


korg's Avatar
Admin from hell
0 0

check here: $ip_test = mysql_query("SELECT * FROM ip_info WHERE ip='$ip'")


ghost's Avatar
0 0

That line looks fine to me…


ghost's Avatar
0 0

masta_hacks wrote: That line looks fine to me…

Have you tried string concatenation with the variables in your SQL statements? Those have to be the most likely point of failure.


ghost's Avatar
0 0

Please explain


ghost's Avatar
0 0

masta_hacks wrote: Please explain

Why don't you fucking Google "string concatenation PHP" and explain it to yourself, you lazy piece of shit?


ghost's Avatar
0 0

when I change ' to " it doesn't work at all. And I know all that is working because thats the script I use for my Registration and it works fine there…


ghost's Avatar
0 0

Read what Korg said and then read you error carefully, i don't know much Php but if you get an error it's never the computers fault it's yours.

[Edit]Apologies if i just posted a load of crap[/Edit]


ghost's Avatar
0 0

omg masta_hacks, learn php properly. that is the single most disgustingly messy piece of php ive ever seen, and i know what youre doing, making a php hacking game right? ive done 50% of one of these myself, and its bloody hard and requires solid php knowledge, which tbh i dont think you fully have. you really should stop setting yourself stupid hard projects for your knowledge level then asking for help when errors appear.