djfox Posted July 17, 2007 Share Posted July 17, 2007 <?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. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 17, 2007 Author Share Posted July 17, 2007 I know that these lines $sel[1] = $echosseller = $echosseller + $p; mysql_query("UPDATE userdata SET echo_count = $echosseller WHERE id = '$s' ") or die(mysql_error()); there`s something in them that`s keeping it from adding. Quote Link to comment Share on other sites More sharing options...
richardw Posted July 17, 2007 Share Posted July 17, 2007 Could you modify the first line in your second post? It sould work for numeric data. <?php $sel[1] = 4; $p = 5; $echosseller = + $p + $sel[1]; echo $echosseller; ?> I hope this helps, Quote Link to comment Share on other sites More sharing options...
djfox Posted July 17, 2007 Author Share Posted July 17, 2007 That code outputs 9. But unfortunately it doesn`t really help me with figuring out what I gotta do to fix my code. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 17, 2007 Share Posted July 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 17, 2007 Author Share Posted July 17, 2007 It`s still not adding. Quote Link to comment Share on other sites More sharing options...
richardw Posted July 17, 2007 Share Posted July 17, 2007 If you are working with an array in one of the "includes", it would be helpful to see that code. What is the data source, a form or a table? Any additonal details will help. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 17, 2007 Author Share Posted July 17, 2007 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; } ?> Quote Link to comment Share on other sites More sharing options...
djfox Posted July 17, 2007 Author Share Posted July 17, 2007 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"; ?> Quote Link to comment Share on other sites More sharing options...
richardw Posted July 17, 2007 Share Posted July 17, 2007 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' Quote Link to comment Share on other sites More sharing options...
djfox Posted July 17, 2007 Author Share Posted July 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
richardw Posted July 17, 2007 Share Posted July 17, 2007 I will be playing with this more later this afternoon... Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted July 17, 2007 Share Posted July 17, 2007 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. Quote Link to comment Share on other sites More sharing options...
djfox Posted July 17, 2007 Author Share Posted July 17, 2007 Oh ok, I see. That got it working but now a new problem has reared it`s ugly head that will require a new thread. x.x Oi, so many problems. Quote Link to comment 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.