Jump to content

[SOLVED] Why is this set of codes not adding?


djfox

Recommended Posts

<?php

include("dbcon.php");
include("func.php");
require_once "auth.php";
require_once "includes/defines.php";

if (!isLoggedIn()) {
Redirect("index.php");
}

$log = $_SESSION['sess_name'];

$res3 = mysql_query("Select id,echo_count FROM userdata WHERE id='$s'")or die( mysql_error() );
$sel = mysql_fetch_row($res3);
mysql_free_result($res3);

if ($_SESSION['echos'] >= $p) {


   $_SESSION['echos'] = $echos = $echos - $p;
   mysql_query("UPDATE userdata SET echo_count = $echos WHERE login = '".$log."' ") or die(mysql_error());
   
   $sel[1] = $echosseller = $echosseller + $p;
   mysql_query("UPDATE userdata SET echo_count = $echosseller WHERE id = '$s' ") or die(mysql_error());
   

mysql_query("INSERT INTO coll_inven (user,item,price) VALUES ( '$log', '$it', '$pr' )");
mysql_query("DELETE FROM coll_sell WHERE id=$id");


header("Location: vendor_grovepark.php");
}
else {
header("Location: vendor_grovepark.php?alert=noechos");
}
?>

 

I want $p added to the current value of $sel[1]

But the codes is not adding to it. Everything else in the code is working fine except for that one part. I`ve been trying to figure it out for about 6 hours now.

Umm what the heck are you trying to do?

 

$sel[1] = $echosseller = $echosseller + $p;

 

You are setting $sel[1] equal to $echosseller which is equal to $echosseller plus $p?

 

That makes no sense at all. Especially since $echosseller has not yet been defined. Please elaborate on what you are actually trying to accomplish if the below does not work for you.

 

$echosseller = $sel[1]+ $p;

OR

$sel[1] += $p;

 

Just make sure that your select statement contains the proper variable, IE either $echosseller or $sel[1] which ever method you choose.

includes:

 

defines:

<?

/* Standard operations */
define('OP_NONE',0);
define('OP_NEW',1);
define('OP_EDIT',2);
define('OP_SAVE',3);
define('OP_DELETE',4);
define('OP_CONFIRM_DELETE',5);

/* misc arrays */

$Gender = array(0=>"Female",1=>"Male");
$Countries = array("None"=>"None",
"AF"=>"Afghanistan",
"ANT"=>"Antarctica",
"AS"=>"Austria",
"AU"=>"Australia",
"BA"=>"Bahamas",
"BE"=>"Belgium",
"BR"=>"Bermuda",
"ZB"=>"Zimbabwe");
$Moods = array(0=>"None",
39=>"Accomplished",
40=>"Aggravated",
160=>"Agony",
41=>"Amused",
12=>"Angry",
155=>"Angsty",
42=>"Annoyed",
43=>"Anxious",
44=>"Apathetic",
10=>"Artistic",
13=>"Ashamed",
149=>"Bitter",
38=>"Worried");
$arttype = array(0=>"New Artist",
7=>"3D Artist",
8=>"Abstract Artist",
9=>"Animator",
1=>"Anime Artist",
33=>"Annoying",
29=>"Antagonist",
2=>"Anthro/Furry Artist",
30=>"Art Appreciator",
49=>"Art Whore",
39=>"Avatar Artist",
10=>"Cartoonist",
50=>"Writer");



/* Page definitions */

$Title = "";

?>

 

Shortened because of the limited space the forum allows to post.

 

 

html:

<?
/*****************************************************************
html.php

Some HTML helpers

******************************************************************/ 

define('CR',"\n");

/* generates a combo from an array */
function ComboBox($Name,$Items,$SelectedValue,$Params='') {

  $res = '<select name="'.$Name.
         '" id="'.$Name.
         '" size="1" style="border: 0px; background-color:#141317; color: #B6ABCE;"'.
         $Params.">\n";
       
  if (Count($Items)>0)
  {
	  foreach($Items as $value=>$item) {
		  $sel=($value==$SelectedValue)?' selected="selected">':">";
		  $res.='<option value="'.$value.'"'.$sel.$item."</option>\n";
       }
  }
  $res.="</select>\n";
      
  echo $res;
}
?>

Data source (if I`m thinking it`s what you`re thinking):

 

vendor_grovepark.php

<?php
//Date: June 23 2007
//For: www.secrettrance.net
//Description: Grove Park Region Market

include("dbcon.php");
require_once "auth.php";
require_once "includes/defines.php";

$Title = "Secret Trance: Regions: The Floating Island: Grove Park: Market";

require_once "header.php";
require_once "hidestatus.php";
?>




<table border=0 width=100%><? //1 
?>
<tr>
<td width=15% valign=top>
<?
require_once "leftbar.php";
?>


<td width=85% valign=top>
<table border=0 width=100%><? //2 
?>
<tr>
<td>
<table border=0 width=100% bgcolor="000000"><? //3
?>
<tr>
<td bgcolor="312D37"><b>Grove Park Region Market</b>
<tr>
<td bgcolor="4A4553">
<table border=0><? //4
?>
<tr>
<td valign=top><img src="vendor_grovepark.png">
<td valign=top>Anime says:
<br>"<SCRIPT LANGUAGE="JAVASCRIPT">
<!--
var r_text = new Array ();
r_text[0] = "Welcome to Grove Park!";
r_text[1] = "Can`t find something in the regular shops? Maybe this market will have it.";
r_text[2] = "You can sell stuff from your inventory here.";
r_text[3] = "Did you set up your shop yet?";
r_text[4] = "Keep an eye out for some good deals.";
r_text[5] = "Did you check out DJ`s shop in Ice Castle City yet?";
r_text[6] = "Stupid humans...";
r_text[7] = "Support the enomays!";
r_text[8] = "I`m really hungry right now...";
r_text[9] = "Welcome to Grove Park!";
var i = Math.round(9*Math.random());

document.write(r_text[i]);

//-->
</SCRIPT>"
<p>
<font size=2><a href="javascript:location.reload()" target="_self">Talk to Anime</a>
<p>
<a href="trancer.php?g=136">Visit Anime</a></font>
</table><? //4
?>
</table><? //3
?>
</table><? //2 
?>


<table border=0 width=100%><? //2 
?>
<tr>
<td>
<tr>
<td>
<table border=0 width=100% bgcolor="000000"><? //3
?>
<tr>
<td bgcolor="312D37"><b>Grove Park Region Market</b>
<tr>
<td bgcolor="4A4553">
<table border=0 width=100%><? //4
?>
<tr>
<td><b>Item</b>
<td><b>Seller</b>
<td><b>Price</b>
<td><b>Buy</b>
<tr>
<? 
if( $lev > 0){
?>
<?php
if (isset($_GET['alert']) && $_GET['alert'] == "noechos") {
echo "<script language=\"javascript\" type=\"text/javascript\">
alert(\"You don't have enough echos for this!\");
</script>";
}
  // should it be $_GET['offset'] ??
  if(isset($offest) && !$offset) $offset=0;
  $recent = 0;
  $res = mysql_query("Select id,seller,item,sellprice,price,sellerid FROM coll_sell ORDER BY id DESC")or die( mysql_error() );

  while( $row = mysql_fetch_row($res) ){
if( $recent >= $offset && $recent < ($offset + 25 )){
	if( $recent%1 == 0 ){
		echo "<tr><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><tr>";
	}
// needs to be named different than what we are looping on.
$res2 = mysql_query("SELECT id, name, description, url, price, preview FROM collection WHERE id='$row[2]'");
$item = mysql_fetch_row($res2);
mysql_free_result($res2);
?>
<td><img src="collection/<? echo "$item[5]" ?>"> <? echo "$item[1]" ?>
<td><a href="trancer.php?g=<? echo"$row[5]" ?>"><? echo "$row[1]" ?></a>
<td><? echo "$row[3]" ?> Echos
<td><a href="sell_coll.php?id=<? echo "$row[0]" ?>&p=<? echo "$row[3]" ?>&pr=<? echo "$row[4]" ?>&s=<? echo "$row[5]" ?>&it=<? echo "$item[0]" ?>">Buy</a>
<?php
  }
$recent = $recent + 1;
}
?>
<?
}
?>

</table><? //4
?>
</table><? //3
?>
</table><? //2 
?>





</table><? //1 
?>




<?
require_once "footer.php";
?>

 

I still don't see the data that you are trying to add. Does it come from a form or the "userdata" table?

 

If it is a form are their checkboxes that you need to loop through and total? Or if a table can their be more than one record id that matches $s

 

 

Select id,echo_count FROM userdata WHERE id='$s'

Select id,echo_count FROM userdata WHERE id='$s'

It`s coming from this:

 

<?php
if (isset($_GET['alert']) && $_GET['alert'] == "noechos") {
echo "<script language=\"javascript\" type=\"text/javascript\">
alert(\"You don't have enough echos for this!\");
</script>";
}
  // should it be $_GET['offset'] ??
  if(isset($offest) && !$offset) $offset=0;
  $recent = 0;
  $res = mysql_query("Select id,seller,item,sellprice,price,sellerid FROM coll_sell ORDER BY id DESC")or die( mysql_error() );

  while( $row = mysql_fetch_row($res) ){



if( $recent >= $offset && $recent < ($offset + 25 )){





if( $recent%1 == 0 ){







echo "<tr><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><td bgcolor='312D37'><tr>";





}



// needs to be named different than what we are looping on.



$res2 = mysql_query("SELECT id, name, description, url, price, preview FROM collection WHERE id='$row[2]'");



$item = mysql_fetch_row($res2);



mysql_free_result($res2);
?>
<td><img src="collection/<? echo "$item[5]" ?>"> <? echo "$item[1]" ?>
<td><a href="trancer.php?g=<? echo"$row[5]" ?>"><? echo "$row[1]" ?></a>
<td><? echo "$row[3]" ?> Echos
<td><a href="sell_coll.php?id=<? echo "$row[0]" ?>&p=<? echo "$row[3]" ?>&pr=<? echo "$row[4]" ?>&s=<? echo "$row[5]" ?>&it=<? echo "$item[0]" ?>">Buy</a>
<?php
  }
$recent = $recent + 1;
}
?>

 

in the vendor_grovepark.php file I posted.

I think you may have your assignment statements backwards because things like:

<?php

$_SESSION['echos'] = $echos = $echos - $p;

?>

 

and:

<?php

$sel[1] = $echosseller = $echosseller + $p;

?>

 

Don't made any sense as neither $echos nor $echosseller appear to be defined anywhere.  Are you sure you don't want something like the following?

<?php

$echos = $_SESSION['echos'];
$echos -= $p;
.
.
.
$echosseller = $sel[1];
$echosseller += $p;

?>

 

Remember, with assignment, the value on the right is put into the variable on the left.

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.