Jump to content

Error In PHP


Steven8294

Recommended Posts

Hey, On my game im trying to Add points and take the money..If you could take a look and tell me if theres anything wrong?

<?
include_once 'includes/db_connect.php';
include_once '../includes/functions.php';
logincheck();

$buy=$_POST['Buy'];

$armage=mysql_fetch_object(mysql_query("SELECT points,money FROM users WHERE username='$username'"));

if($buy){
$price=1000000;
if($points->money < $price){
print"<p class='warning'>You dont have enough money to buy 100 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='100' WHERE username='$username'");
print"<p class='success'>You bought 100 points.</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
if($buy){
$price=2000000;
if($points->money < $price){
print"<p class='warning'>You dont have enough money to buy 200 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='200' WHERE username='$username'");
print"<p class='success'>You bought 200 points.</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
if($buy){
$price=4500000;
if($points->money < $price){
print"<p class='warning'>You dont have enough money to buy 500 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='500' WHERE username='$username'");
print"<p class='success'>You bought 500 points.</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
if($buy){
$price=9000000;
if($points->$money < $price){
print"<p class='warning'>You dont have enough money to buy 1000 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='1000' WHERE username='$username'");
print"<p class='success'>You bought 1000 points</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<link href="../stylesheets/online.css" rel="stylesheet" type="text/css" />
<script language=JavaScript>
function so(dis)
{
for (i=0;i<dis.elements.length;i++){ 
if (dis.elements[i].type=='submit')
   dis.elements[i].style.visibility='hidden';
}
if(fs==false){
	 fs=true;
	 return true;
}else
		return false;
}
function goaway()
{
for(i=0;i<document.forms.length;i++)
document.forms[i].onsubmit = function() {return so(this);};
}
</script>
</head>

<body onLoad="goaway();">     <form id="form1" name="form1" method="post" action="">
<table width="300" border="0" align="center" cellspacing="0" class="background">
  <tr class="header">
    <th scope="col">Page Under Construction </th>
  </tr>
</table>
<p> </p>
<table width="631" border="0" align="center" cellspacing="0" class="background">
  <tr class="header">
    <th colspan="2" scope="col">Buy Points</th>
  </tr>
      
  </tr>
  <tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>100 </strong>Points.</p>
      <p><strong>Price:</strong> £1,000,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="100 Points" />
        </div>
      </th>
  </tr>
  <tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>200 </strong>Points.</p>
      <p><strong>Price:</strong> £2,000,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="200 Points" />
        </div>
      </th>
  </tr>  
<tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>500 </strong>Points.</p>
      <p><strong>Price:</strong> £4,500,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="500 Points" />
        </div>
      </th>
  </tr>  
<tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>1000 </strong>Points.</p>
      <p><strong>Price:</strong> £9,000,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="1000 Points" />
    </div>
      </th>
  </tr>  
</table> </form>
<p> </p>
</body>
</html>
<? include_once 'footer.php'; ?>

 

I GET THE ERROR:

You dont have enough money to buy 100 points.

You dont have enough money to buy 200 points.

You dont have enough money to buy 500 points.

You dont have enough money to buy 1000 points.

Link to comment
Share on other sites

<?
include_once '../includes/db_connect.php';
include_once '../includes/functions.php';
logincheck();

$buy=$_POST['Buy'];

$armage=mysql_fetch_object(mysql_query("SELECT points,money FROM users WHERE username='$username'"));

if($buy){
$price=1000000;
if($points->$money < $price){
print"<p class='warning'>You dont have enough money to buy 100 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='100' WHERE username='$username'");
print"<p class='success'>You bought 100 points.</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
if($buy){
$price=2000000;
if($points->$money < $price){
print"<p class='warning'>You dont have enough money to buy 200 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='200' WHERE username='$username'");
print"<p class='success'>You bought 200 points.</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
if($buy){
$price=4500000;
if($points->$money < $price){
print"<p class='warning'>You dont have enough money to buy 500 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='500' WHERE username='$username'");
print"<p class='success'>You bought 500 points.</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
if($buy){
$price=9000000;
if($points->$money < $price){
print"<p class='warning'>You dont have enough money to buy 1000 points.</p>"; 
}else{
$equ=$user->points-$price;
mysql_query("UPDATE users SET money='$newage' WHERE username='$username'");
mysql_query("UPDATE users SET points='1000' WHERE username='$username'");
print"<p class='success'>You bought 1000 points</p>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=\">";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<link href="../stylesheets/online.css" rel="stylesheet" type="text/css" />
<script language=JavaScript>
function so(dis)
{
for (i=0;i<dis.elements.length;i++){ 
if (dis.elements[i].type=='submit')
   dis.elements[i].style.visibility='hidden';
}
if(fs==false){
	 fs=true;
	 return true;
}else
		return false;
}
function goaway()
{
for(i=0;i<document.forms.length;i++)
document.forms[i].onsubmit = function() {return so(this);};
}
</script>
</head>

<body onLoad="goaway();">     <form id="form1" name="form1" method="post" action="">
<table width="300" border="0" align="center" cellspacing="0" class="background">
  <tr class="header">
    <th scope="col">Page Under Construction </th>
  </tr>
</table>
<p> </p>
<table width="631" border="0" align="center" cellspacing="0" class="background">
  <tr class="header">
    <th colspan="2" scope="col">Buy Points</th>
  </tr>
      
  </tr>
  <tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>100 </strong>Points.</p>
      <p><strong>Price:</strong> £1,000,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="100 Points" />
        </div>
      </th>
  </tr>
  <tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>200 </strong>Points.</p>
      <p><strong>Price:</strong> £2,000,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="200 Points" />
        </div>
      </th>
  </tr>  
<tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>500 </strong>Points.</p>
      <p><strong>Price:</strong> £4,500,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="500 Points" />
        </div>
      </th>
  </tr>  
<tr>
    <th align="left" valign="top" class="background" scope="row"><p><strong>1000 </strong>Points.</p>
      <p><strong>Price:</strong> £9,000,000</p>
    <div align="center">
        <input name="Buy" type="submit" class="button" value="1000 Points" />
    </div>
      </th>
  </tr>  
</table> </form>
<p> </p>
</body>
</html>
<? include_once 'footer.php'; ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.