Jump to content

Parse error on script.


Alecdude

Recommended Posts

Parse error: parse error, unexpected T_LOGICAL_AND in /home/content/a/l/e/alecdude/html/login/badge1.php on line 12

 

This is happening on this script, and I'm not sure why:

<?php
session_start();
include 'dbc.php';

if (!isset($_SESSION['user']))
{
die ("<h3>You are not logged in.</h3> <p>You have to <a href=http://www.aroltd.com/login/login.php>login</a> to access this page.");
}

if ($_POST['Submit']=='Buy this badge')
{
if ($_SESSION['Money'] >= 15) and ($_SESSION['badge1'] = 0){
     $sql = "UPDATE users SET "$_SESSION['Money']" = "$_SESSION['Money']" - 15 AND UPDATE users SET "$_SESSION['badge1']" = 1";
 $result = mysql_query($sql) or die (mysql_error()); 
 echo "<h3>You have received your badge!</h3><br><a href=myaccount.php>Click here to go to your account</a>";
} else {
echo "<h3>You either own this badge or do not have enough ARO$.</h3><br><p>Please click the back button to go back a page.</p>"; }
}

?> 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link REL="SHORTCUT ICON" HREF="http://www.aroltd.here/favicon.ico">
<title>AROLTD (Pronouned Arrow Limited)</title>
<link rel="stylesheet" href="http://www.aroltd.com/styles.css" type="text/css" />
<link href="styles.css" rel="stylesheet" type="text/css">
<style type="text/css">
img
{
    border-color: black;
    border-width: 3px;
    border-style: dashed;
}
</style>
</head>
<?php if (isset($_GET['msg'])) { echo "<div class=\"msg\"> $_GET[msg] </div>"; } ?>
<body background="images/page_background.gif">
<div id="wrap">
<div id="header">
	<h1>AroAccounts</h1>
	<?php if (isset($_SESSION['Money'])) { ?>
	<h2>ARO$: <?php echo $_SESSION['Money']; ?></h2>
	<?php } ?>  
</div>
<div id="nav">
	<ul>
		<li><a href="http://www.aroltd.com/login/myaccount.php" title="Home">AroAccounts</a></li>
		<li><a href="#" class="selected" title="Store">Badge Store</a></li>
		<li><a href="http://www.aroltd.com/" title="Games">Regular Site</a></li>
	</ul>
</div>
<div id="content">
	<div id="page">
<img src="burger.png" align="left">
<h2 align="center">The Awfsum Badge uv Cheezburger</h2>
<hr>
<h2 align="center">Description:</h2>
<h3 align="justify">The owners of this badge proudly support beta testing this feature of the site - it is a privledge to own this badge, as it says proudly that 'I was there'. The reason this badge has to do with cheeseburgers and has misspellings is unknown, and probably will remain as such.
<center><input name="Submit" type="submit" id="Submit" value="Buy this badge"></center>
<p>

</p>
	</div>
	<div id="sidebar">
		<h4>Other Items</h4>
		<p>
		<!-- BEGIN MYSHOUTBOX.COM CODE -->
		<center><iframe src="http://560780.myshoutbox.com/" width="160" height="500" frameborder="0" allowTransparency="true"></iframe></center>
		<!-- END MYSHOUTBOX.COM CODE-->
		</p>
		<p><center><!-- Start of StatCounter Code -->
		<script type="text/javascript">
		sc_project=3356994; 
		sc_invisible=0; 
		sc_partition=36; 
		sc_security="1ecd8f40"; 
		</script>
		<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script><noscript><div class="statcounter"><a href="http://www.statcounter.com/free_hit_counter.html" target="_blank"><img class="statcounter" src="http://c37.statcounter.com/3356994/0/1ecd8f40/0/" alt="hitcounter" ></a></div></noscript>
		<!-- End of StatCounter Code --></p></center>
		<h4>Sponsors</h4>
		<ul>
			<li><a href="http://www.mrbltd.co.nr" title="Game Reviews">MrbLtd</a></li>
			<li><a href="http://www.freewebs.com/cheatfarn" title="Cheats For My Games">CheatFarn</a></li>
			<li>Want your link here? I have to know you in real life to put up a link to your site, so ask me at school please.</li>
		</ul>
	</div>
	<div id="footer">
		<p>© 2008 AroLtd. All rights reserved under a liscense I made up.</p>
	</div>
</div>
</div>
</body>
</html>

 

Please fix this, as I have no clue why I am getting this error. If you are unsure as well of why this error is happening, please feel free to request more information, and I shall give it to you.

 

Thanks,

-Alec

Link to comment
Share on other sites

<?php if ($_SESSION['Money'] >= 15) and ($_SESSION['badge1'] = 0){?>

 

should be:

<?php

if ($_SESSION['Money'] >= 15) && ($_SESSION['badge1'] = 0){?>

 

Now i get this:

Parse error: parse error, unexpected T_BOOLEAN_AND in /home/content/a/l/e/alecdude/html/login/badge1.php on line 12

Link to comment
Share on other sites

 

<?php

if ($_SESSION['Money'] >= 15 && $_SESSION['badge1'] = 0){?>

 

Now I get this:

Parse error: parse error, unexpected T_VARIABLE in /home/content/a/l/e/alecdude/html/login/badge1.php on line 13

 

Lotsa errors.

 

if (($_SESSION['Money'] >= 15) and ($_SESSION['badge1'] == 0)){

also, I'm pretty sure you meant to use '==' instead of '='

 

(You must have open/closing parentheses for if() statements)

 

I also did that, and am getting the same error.

Link to comment
Share on other sites

   $sql = "UPDATE users SET ".$_SESSION['Money']." = ".$_SESSION['Money']." - 15 AND UPDATE users SET ".$_SESSION['badge1']." = 1";

 

periods for string concatenation

<?php
$sql = "UPDATE users SET "{$_SESSION['Money']}" = "{$_SESSION['Money']}" - 15 AND UPDATE users SET "{$_SESSION['badge1']}" = 1";?>

 

This will also work ;D

 

Ok, those caused the page to appear, but the code does not execute. Nothing happens when you press the button.

 

So, that's the new problem.

Link to comment
Share on other sites

<?php
if ($_POST['Submit']=='Buy this badge'){
if ($_SESSION['Money'] >= 15)&& $_SESSION['badge1'] = 0){
     $sql = "UPDATE users SET "$_SESSION['Money']" = "$_SESSION['Money']" - 15 AND UPDATE users SET "$_SESSION['badge1']" = 1";
 $result = mysql_query($sql) or die (mysql_error()); 
 echo "<h3>You have received your badge!</h3><br><a href=myaccount.php>Click here to go to your account</a>";
} else {
echo "<h3>You either own this badge or do not have enough ARO$.</h3><br><p>Please click the back button to go back a page.</p>"; }
}
?> 

UPDATE users SET ".$_SESSION['Money']." = "$_SESSION['Money']...

should probably be UPDATE users SET money = ".$_SESSION['Money']...

 

$_SESSION['badge1'] should be equal to the field for badge1 I'm guessing.

 

Since your current code makes the query eval to "SET 0 = 1" which is wrong.

Link to comment
Share on other sites

<?php
if ($_POST['Submit']=='Buy this badge'){
if ($_SESSION['Money'] >= 15)&& $_SESSION['badge1'] = 0){
     $sql = "UPDATE users SET "$_SESSION['Money']" = "$_SESSION['Money']" - 15 AND UPDATE users SET "$_SESSION['badge1']" = 1";
 $result = mysql_query($sql) or die (mysql_error()); 
 echo "<h3>You have received your badge!</h3><br><a href=myaccount.php>Click here to go to your account</a>";
} else {
echo "<h3>You either own this badge or do not have enough ARO$.</h3><br><p>Please click the back button to go back a page.</p>"; }
}
?> 

UPDATE users SET ".$_SESSION['Money']." = "$_SESSION['Money']...

should probably be UPDATE users SET money = ".$_SESSION['Money']...

 

$_SESSION['badge1'] should be equal to the field for badge1 I'm guessing.

 

Since your current code makes the query eval to "SET 0 = 1" which is wrong.

 

Now it executes, but I have enough money and do not own the badge, and it gives me the "You don't have enough ARO$ or own the badge already" message.

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.