Steven8294 Posted January 17, 2008 Share Posted January 17, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/86478-error-in-php/ Share on other sites More sharing options...
Steven8294 Posted January 17, 2008 Author Share Posted January 17, 2008 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/86478-error-in-php/#findComment-441894 Share on other sites More sharing options...
trq Posted January 17, 2008 Share Posted January 17, 2008 Can you at least narrow your problem down to the relevent parts, use the proper <?php tags so we get syntax highlighting and indent your code so it is readable? Quote Link to comment https://forums.phpfreaks.com/topic/86478-error-in-php/#findComment-441905 Share on other sites More sharing options...
Steven8294 Posted January 17, 2008 Author Share Posted January 17, 2008 <? 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'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86478-error-in-php/#findComment-441912 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.