Jump to content

[SOLVED] Can someone check my code, please?


Tmal

Recommended Posts

Hey Ive gone thru my code about 100 times and I cant find any errors but its not echoing the information as it is supposed to,

 

can anyone take a look and see if I did something wrong?

 

Thanks for any views and reply's

 

<?php
if($_GET['type']=="untrained"){

	$ammount = $_GET['ammount'];

	$troops = ($ammount * 1500);

$sql = "SELECT * FROM `UserInfo` WHERE `id` = '$id'";
  $row = mysql_fetch_array(mysql_query($sql));
  
  if($row['id'] != $id){
$msg=("HACK ATTEMPT DETECTED!");
echo($msg);	
                       }
                       else{
  
  $tokens = $row['tokens'];
  if($tokens >= $ammount){

$update="UPDATE `EmpireBank` SET `Untrained` = `Untrained` +'$troops' WHERE `owner` = '$id'";

$update2="UPDATE `UserInfo` SET `tokens` = `tokens` -'$ammount' WHERE `id` = '$id'";

$res=mysql_query($update);


$res2=mysql_query($update2);




if(isset($res) && isset($res2)){

$msg=("You have just bought ".number_format($troops)." untrained for ".number_format($ammount)." ULC Tokens");
echo($msg);	

}else{
$msg="Something Went Awfully Wront :S";
echo $msg;
}


}else{
$msg=("Not enough ULC Tokens");
echo($msg);	
}
}
  
  }
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/166929-solved-can-someone-check-my-code-please/
Share on other sites

Did you get any error?

 

Try this:

if(isset($res) && isset($res2)){

to this:

if($res && $res2){

 

You better use error tracking for script and queries like:

At top of the script:

error_reporting (E_ALL);

 

And for query:

$res=mysql_query($update) or die (mysql_error());

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.