Jump to content

update mysql problem


dansendewc

Recommended Posts

Hey I'm kind of new in php did alot of javascript and html before, wanted to try to make an php game.

 

I got an problem with:

 

mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");

 

in jail.php.

 

The weerd thing is that I use allot of same sort scripts after it

 

like

mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");

.

 

Also I use

 

mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");

 

at crime.php and  it is exact the same code but it works

 

So there must be an error that isnt part of the query if I am correct

 

jail.php

<?php

//Checks If People Are Logged In If Not Send Them To The Homepage.


// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
	$username = $_COOKIE['ID_my_site'];
	$pass = $_COOKIE['Key_my_site'];
	 	$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
	while($info = mysql_fetch_array( $check ))
		{

//if the cookie has the wrong password, they are taken to the login page
		if ($pass != $info['password'])
			{ 			header("Location: index.php");
			}

//otherwise they are shown the admin area
	else
			{

			}
		}
		}
else

//if the cookie does not exist, they are taken to the login screen
{header("location: index.php"); }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php

//ALL VARIABLES WITH THERE STANDARD VALUE

;?>

<?php $date = date
("D d M Y H:i:s");
$today = time () ;
$while=" while ";
?>

<?php

// ASK ALL THE DATA NEEDED FROM THE DATABASE

      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql4 = "SELECT cash FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result4 = mysql_query($sql4) or die (mysql_error());
      $rows4 = mysql_fetch_array($result4);

      $cash = $rows4['cash'];
?>

<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql5 = "SELECT bank FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result5 = mysql_query($sql5) or die (mysql_error());
      $rows5 = mysql_fetch_array($result5);

      $bank = $rows5['bank'];
?>
<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql6 = "SELECT life FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result6 = mysql_query($sql6) or die (mysql_error());
      $rows6 = mysql_fetch_array($result6);

      $life = $rows6['life'];
?>

<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql7 = "SELECT whore FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result7 = mysql_query($sql7) or die (mysql_error());
      $rows7 = mysql_fetch_array($result7);

      $whore = $rows7['whore'];
?>

<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql8 = "SELECT bullets FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result8 = mysql_query($sql8) or die (mysql_error());
      $rows8 = mysql_fetch_array($result8);

      $bullets = $rows8['bullets'];
?>

<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die("cannot select database.");
$sql9 = "SELECT earned FROM users WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' ";
$result9 = mysql_query ($sql9) or die (mysql_error());
$rows9 = mysql_fetch_array($result9);

$earned=$rows9['earned'];
?>
<?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql10 = "SELECT crime FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result10 = mysql_query($sql10) or die (mysql_error());
      $rows10 = mysql_fetch_array($result10);
      $crime = $rows10['crime'];
      ?>
<?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql11 = "SELECT jail FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result11 = mysql_query($sql11) or die (mysql_error());
      $rows11 = mysql_fetch_array($result11);
      $jail = $rows11['jail']; ?>

       <?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql12 = "SELECT jailname FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result12 = mysql_query($sql12) or die (mysql_error());
      $rows12 = mysql_fetch_array($result12);
      $jailname = $rows12['jailname']; ?>

      <?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql13 = "SELECT xp FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result13 = mysql_query($sql13) or die (mysql_error());
      $rows13 = mysql_fetch_array($result13);
      $xp = $rows13['xp']; ?>

<?php

  $jailtimer = $jail-$today ;
      $mins= floor ($jailtimer / 60) ;
      $seconds = $jailtimer % 60 ;
      $jailtimerjava = $jailtimer * 1000;
      ?>


<title>Hostile City</title>

<link rel="stylesheet" href="styles.css" type="text/css" />
<?php if($jail-$today>0){; ?>
</head>
<body onload="timer=setTimeout('move()',<?php echo $jailtimerjava; ?>)">

<div id="container">
<div id="header">
	<h1>Aftershock!</h1>
	<p>We provide gameplay you remember.</p>
</div>
<div id="nav">
	<ul>
		<li><a href="members.php" title="safe house">safe house</a></li>
		<li><a href="crime.php" title="crime">crime</a></li>
		<li><a href="shop.php" title="go shopping">shop</a></li>
		<li><a href="casino.php" title="start gambling">casino</a></li>
		<li><a href="jail.php" title="jail">jail</a></li>
		<li><a href="contact.php" title="contact">contact</a></li>
		<li><a href="logout.php" tittle="logout">logout</a></li>
	</ul>
	</div>
<div id="content">
	<div id="page">
	<h3>You are In jail for <?php if($mins>0){echo $mins." minutes and ".$seconds." seconds";}else{echo $seconds." seconds";} ?></h3><br>
	<h3>All inmates:</h3><br>
      <?php mysql_connect("localhost","root","");
      mysql_select_db("users");
      $sql11 = "SELECT jailname FROM users";
      $result11 = mysql_query($sql11) ;
      while($row = mysql_fetch_array($result11))
  { if(isset($row['jailname'])){echo $row['jailname'];
  echo "<br />";
  }else{
  ;}}?>

	</div>
	<div class="clear"></div>
</div>

</div>
</body>

</html>
<?php ;}else{ ;?>

<?php

if(isset($_POST['breakoutvalue'])){if($xp<40000){$lol = rand(1,2);
if($lol*40000>300000){
	$breakout=$_POST['breakoutvalue'];
	  mysql_connect("localhost","root","")or die(mysql_error());
  mysql_select_db("users")or die("Cannot select database.");
   	  $sql13 = "UPDATE users SET jailname= null WHERE username = '$breakout' ";
      $result13 = mysql_query($sql13) or die (mysql_error());}else{mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
      $breakouttime = $lol * 0;
      $jailtime = $breakouttime+$today;
   	  mysql_query("UPDATE users SET jail = '$jailtime' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
   	  $string = "You have been arrested".$while."breakingout ".$_POST['breakoutvalue'];mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' ");
   	  header("Location:jail.php") ;}}else{$lol = rand(1,10);
      if($lol*$xp>300000){$breakout=$_POST['breakoutvalue'];
	  mysql_connect("localhost","root","")or die(mysql_error());
  mysql_select_db("users")or die("Cannot select database.");
   	  $sql13 = "UPDATE users SET jailname= null WHERE username = '$breakout' ";
      $result13 = mysql_query($sql13) or die (mysql_error());}else{
      mysql_connect("localhost","root","");
      mysql_select_db("users");
      $breakouttime = $lol * 20;
      $jailtime = $breakouttime+$today;
      mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
   	  mysql_query("UPDATE users SET jail = '$jailtime' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
   	  $string = "You have been arrested".$while."breakingout " ;mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' ");
   	  header("Location:jail.php") ;}}}?>

</head>
<body>

<?php mysql_connect("localhost","root","")or die(mysql_error());
  mysql_select_db("users")or die("Cannot select database.");
   	  $sql12 = "UPDATE users SET jailname= null WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'";
      $result12 = mysql_query($sql12) or die (mysql_error()); echo $_COOKIE['ID_my_site'];?>


<div id="container">
<div id="header">
	<h1>Aftershock!</h1>
	<p>We provide gameplay you remember.</p>
</div>
<div id="nav">
	<ul>
		<li><a href="members.php" title="safe house">safe house</a></li>
		<li><a href="crime.php" title="crime">crime</a></li>
		<li><a href="shop.php" title="go shopping">shop</a></li>
		<li><a href="casino.php" title="start gambling">casino</a></li>
		<li><a href="jail.php" title="jail">jail</a></li>
		<li><a href="contact.php" title="contact">contact</a></li>
		<li><a href="logout.php" tittle="logout">logout</a></li>
	</ul>
	</div>
<div id="content">
	<div id="page">
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
          <table>
          <?php mysql_connect("localhost","root","");
      mysql_select_db("users");
      $sql11 = "SELECT jailname FROM users";
      $result11 = mysql_query($sql11) ;
      while($row = mysql_fetch_array($result11))
  { if(isset($row['jailname'])){ $rowjailname=$row['jailname'];
echo
"<tr>
<td id='stat' width='320'>";echo $row['jailname']; echo"</td>
<td id='stat'><input type='radio' name='breakoutvalue' value='$rowjailname'></td>
</tr>";
  }else{
  ;}}?>
  </table>
  <input type="submit" value="breakout" name="breakout" onclick=>
  </form>
  </div>
	<div class="clear"></div>
</div>

</div>



</body>
</html>
<?php ;}?>

This is the script where it wont work. line 217 and  232

 

 

crime.php

<?php

//Checks If People Are Logged In If Not Send Them To The Homepage.


// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
	$username = $_COOKIE['ID_my_site'];
	$pass = $_COOKIE['Key_my_site'];
	 	$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
	while($info = mysql_fetch_array( $check ))
		{

//if the cookie has the wrong password, they are taken to the login page
		if ($pass != $info['password'])
			{ 			header("Location: index.php");
			}

//otherwise they are shown the admin area
	else
			{

			}
		}
		}
else

//if the cookie does not exist, they are taken to the login screen
{header("location: index.php"); }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php $date = date
("D d M Y H:i:s");
$today = time () ;
$error="Sorry, The Website Has Found A Error, Please Relog";
$with=" with ";
$while=" while ";
$string="";
?>

<?php

// ASK ALL THE DATA NEEDED FROM THE DATABASE

      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql4 = "SELECT cash FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result4 = mysql_query($sql4) or die (mysql_error());
      $rows4 = mysql_fetch_array($result4);

      $cash = $rows4['cash'];
?>

<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql5 = "SELECT bank FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result5 = mysql_query($sql5) or die (mysql_error());
      $rows5 = mysql_fetch_array($result5);

      $bank = $rows5['bank'];
?>
<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql6 = "SELECT life FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result6 = mysql_query($sql6) or die (mysql_error());
      $rows6 = mysql_fetch_array($result6);

      $life = $rows6['life'];
?>

<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql7 = "SELECT whore FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result7 = mysql_query($sql7) or die (mysql_error());
      $rows7 = mysql_fetch_array($result7);

      $whore = $rows7['whore'];
?>

<?php
      mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql8 = "SELECT bullets FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result8 = mysql_query($sql8) or die (mysql_error());
      $rows8 = mysql_fetch_array($result8);

      $bullets = $rows8['bullets'];
?>

<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die("cannot select database.");
$sql9 = "SELECT earned FROM users WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' ";
$result9 = mysql_query ($sql9) or die (mysql_error());
$rows9 = mysql_fetch_array($result9);

$earned=$rows9['earned'];
?>
<?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql10 = "SELECT crime FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result10 = mysql_query($sql10) or die (mysql_error());
      $rows10 = mysql_fetch_array($result10);
      $crime = $rows10['crime'];
      $timestap= $crime-$today  ;
      $mins= floor ($timestap / 60) ;
      $seconds = $timestap % 60 ;
      ?>
<?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql11 = "SELECT jail FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result11 = mysql_query($sql11) or die (mysql_error());
      $rows11 = mysql_fetch_array($result11);
      $jail = $rows11['jail']; ?>

       <?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql12 = "SELECT jailname FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result12 = mysql_query($sql12) or die (mysql_error());
      $rows12 = mysql_fetch_array($result12);
      $jailname = $rows12['jailname']; ?>

      <?php
mysql_connect("localhost","root","")or die(mysql_error());
      mysql_select_db("users")or die("Cannot select database.");

      $sql13 = "SELECT xp FROM users WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]' ";
      $result13 = mysql_query($sql13) or die (mysql_error());
      $rows13 = mysql_fetch_array($result13);
      $xp = $rows13['xp']; ?>




<?php


// POST


mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("users") or die(mysql_error());

  if (isset($_POST['submit'])) {
  if (isset($_POST['depost'])) {
  	$bank2 = $bank+($_POST['depost']);
  	$cash3 = $cash-$_POST['depost'];
  	$cash4 = $cash-$_POST['depost']+$_POST['withdraw'];
  	if ($cash4>-1){
  	mysql_query("UPDATE users SET bank = $bank2 WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' ");
  	mysql_query("UPDATE users SET cash = $cash3 WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
      $bank=$bank2;
      $cash=$cash3;}else{header("Location:index.php") ;}
  if (isset($_POST['withdraw'])){
  	$cash2 = $cash + ($_POST['withdraw']);
  	$bank3 = $bank-$_POST['withdraw'];
  	$bank4 = $bank-$_POST['withdraw']+$_POST['depost'];
  if ($bank4>-1){
    mysql_query("UPDATE users SET cash = $cash2 WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
    mysql_query("UPDATE users SET bank = $bank3 WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
    $cash=$cash2;
    $bank=$bank3;
      }}}else{header("Location:index.php");}}
?>

<?php

  $crimetimer = $crime-$today ;
      $mins= floor ($crimetimer / 60) ;
      $seconds = $crimetimer % 60 ;
      $crimestap = $today+90 ;?>

<?php

//WIDGET

if(isset($_POST["crime_1"])){
$your_crime=$_POST["crime_1"];
if ($your_crime=="sending out fake bills."){ $lol=rand (1,15); if ($lol>5){
$money=$lol*38;
$string="You have earned ".$money."$".$with.$your_crime;
mysql_connect("localhost","root","");
mysql_select_db("users");
mysql_query("UPDATE users SET cash = $money+$cash WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET crime = $crimestap WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");$cash = $money+$cash; header("Location:members.php") ;}else{mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");$loljail= $lol*4; $jailstap2 = $today+$loljail ; mysql_query("UPDATE users SET jail = '$jailstap2' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  "); $string = "You have been arrested".$while.$your_crime; $checker = 'done';mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' "); header("Location:jail.php") ;}}elseif($your_crime=="stealing the copper wire from a substation."){
$lol=rand (1,25); if ($lol>25){
$money=$lol*38;
$string= "You have earned ".$money."$".$with.$your_crime;
mysql_connect("localhost","root","");
mysql_select_db("users");
mysql_query("UPDATE users SET cash = $money+$cash WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET crime = $crimestap WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");$cash = $money+$cash; header("Location:members.php") ;}else{mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  "); $loljail= $lol*4; $jailstap2 = $today+$loljail ; mysql_query("UPDATE users SET jail = '$jailstap2' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  "); $string = "You have been arrested".$while.$your_crime; $checker = 'done';mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' "); header("Location:jail.php") ;}}elseif($your_crime=="playing homeless."){
$lol=rand (1,10); if ($lol>2){
$money=$lol*7;
$string="You have earned ".$money."$".$with.$your_crime;
mysql_connect("localhost","root","");
mysql_select_db("users");
mysql_query("UPDATE users SET cash = $money+$cash WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET crime = $crimestap WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");$cash = $money+$cash; header("Location:members.php") ;}else{mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");$loljail= $lol*4; $jailstap2 = $today+$loljail ; mysql_query("UPDATE users SET jail = '$jailstap2' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' "); $string = "You have been arrested".$while.$your_crime; $checker = 'done';mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]' "); header("Location:jail.php") ;}}elseif($your_crime=="stealing a schoolbag."){
$lol=rand (1,5);
$money=$lol*3;
$string="You have earned ".$money."$".$with.$your_crime;
mysql_connect("localhost","root","");
mysql_select_db("users");
mysql_query("UPDATE users SET cash = $money+$cash WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET earned = '$string' WHERE username = '$_COOKIE[iD_my_site]'&& password = '$_COOKIE[Key_my_site]'   ");
mysql_query("UPDATE users SET crime = $crimestap WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");$cash = $money+$cash; header("Location:members.php") ;}else{echo $error;}}?>

<?php if($jailname == null){;}else{header("location:jail.php");} ?>

<title>Hostile City</title>
<link rel="stylesheet" href="styles.css" type="text/css" />
<?php if($crime<$today){ ; ?>
</head>


<body>

<div id="container">
<div id="header">
	<h1>Aftershock!</h1>
	<p>We provide gameplay you remember.</p>
</div>
<div id="nav">
	<ul>
		<li><a href="members.php" title="safe house">safe house</a></li>
		<li><a href="crime.php" title="crime">crime</a></li>
		<li><a href="shop.php" title="go shopping">shop</a></li>
		<li><a href="start_guide.php" title="start guide">guide</a></li>
		<li><a href="black_joe.php" title="the story">black joe</a></li>
		<li><a href="contact.php" title="contact">contact</a></li>
		<li><a href="logout.php" tittle="logout">logout</a></li>
	</ul>
	</div>
<div id="content">
	<div id="page"><br><br>
	<div id="frame">
         <form id="crime" action=""  method="post">
<input type="radio" name="crime_1" value="stealing a schoolbag." />Steal a schoolbag.<br>
<input type="radio" name="crime_1" value="playing homeless." />Play homeless and collect some free cash.<br>
<input type="radio" name="crime_1" value="sending out fake bills." />Send out fake bills.<br>
<input type="radio" name="crime_1" value="stealing the copper wire from a substation." />Steal the copper wire from a substation.
<br>
<input type="submit" value="Submit" />
</form>
	</div>
	</div>
	<div id="sidebar">
		<h4>You got <?php echo $cash ?>$ to spend.</h4>
		<br>
		<?php echo $date; ?><br>
		<p>----------------------</p>
		<h4>Links</h4>
            <p>Want to become a "Link Partner"<br><a href="contact.php">please contact.</a></p>
	</div>
	<div class="clear"></div>
</div>

</div>

</body>

</html>

<?php ;}else{ ;?>

<div id="container">
<div id="header">
	<h1>Aftershock!</h1>
	<p>We provide gameplay you remember.</p>
</div>
<div id="nav">
	<ul>
		<li><a href="members.php" title="safe house">safe house</a></li>
		<li><a href="crime.php" title="crime">crime</a></li>
		<li><a href="shop.php" title="go shopping">shop</a></li>
		<li><a href="start_guide.php" title="start guide">guide</a></li>
		<li><a href="black_joe.php" title="the story">black joe</a></li>
		<li><a href="contact.php" title="contact">contact</a></li>
		<li><a href="logout.php" tittle="logout">logout</a></li>
	</ul>
	</div>
<div id="content">
	<div id="page"><br><br>
	<h3><?php $string="You already commited a crime recently. Try again in "; if($mins>0){echo $string.$mins." minutes and ".$seconds." seconds";}else{echo $string.$seconds." seconds";} ?></h3><br>

	</div>
	<div id="sidebar">
		<h4>You got <?php echo $cash ;?>$ to spend.</h4>
		<br>
		<?php echo $date; ?><br>
		<p>----------------------</p>
		<h4>Links</h4>
            <p>Want to become a "Link Partner"<br><a href="contact.php">please contact.</a></p>
	</div>
	<div class="clear"></div>
</div>

</div>
</div>
</div>

</body>
</html>
<?php ;} ?>

This script works line 208, 216, 224

 

There must be somthing rong already looking for like 5 hours cant find anything.

 

So how can i get the script on jail.php working, everything else works correctly.

 

I add the files at this post

 

 

 

 

 

The $_COOKIE['ID_my_site'] and [Key_my_site] are cookies you get when you log in. to target the right columns

 

 

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/208733-update-mysql-problem/
Share on other sites

First, you'll want to get in the habit of separating the query string from the query execution. It makes debugging easier. Then add the or die() for testing. Change die() to  trigger_error() for live use, and check for a result

$query = "SELECT whatever FROM table WHERE field = 3"
$result = mysql_query($query) or die( 'Query string: ' . $query . '<br />Cratered with error: ' . mysql_error() ); 

if($result) { 
     //do something, echo output, whatever.
} else { 
      //error, so present generic error message
}

 

 

Also, any time you use a header() redirect, you need to issue an exit() to stop the script from executing further

} else { 
     header("location: index.php");
     exit();
}

$sql14 = ("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");
      $result14 = mysql_query($sql14) or die( 'Query string: ' . $sql14 . '<br />Cratered with error: ' . mysql_error() );
      if($result14==$_COOKIE['ID_my_site']){echo 'goodjob';}else{die (mysql_error());}

The code dont displays any error

 

I'm kind of newb  i know. still would like the code to work

mysql_query("UPDATE users SET jailname = '$_COOKIE[iD_my_site]' WHERE username = '$_COOKIE[iD_my_site]' && password = '$_COOKIE[Key_my_site]'  ");

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.