Jump to content

Why isn`t this code working?


djfox

Recommended Posts

First the background story:

I`ve had this strip of coding working for several months, never touched it. The server host has changed something where all of my codes went into a seizure and no longer work so I`ve had to rebuild my site to get everything to work.

 

The code that needs looking over:

<?php
session_start();

include("dbcon.php");
include("func.php");
require_once "auth.php";
require_once "design.php";

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

if ($lev > 0) {
$log = $_SESSION['sess_name'];
$id = $_POST['id'];
$p = $_POST['p'];
$pr = $_POST['pr'];
$s = $_POST['s'];
$it = $_POST['it'];
$n = $_POST['n'];

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

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

$res = mysql_query("SELECT id,seller,item,sellprice,price,sellerid FROM coll_sell WHERE id=$id");
$chap = mysql_fetch_row($res);
mysql_free_result($res);

$_SESSION['echos'] = $echos = $echos - $chap[3];

   mysql_query("UPDATE userdata SET echo_count='$echos' WHERE id='$logged' ") or die(mysql_error());
   
mysql_query("INSERT INTO sales (seller,buyer,item,echos) VALUES ( '$sel[1]', '$log', '$n', '$p' )");

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

$entry_date = strftime("%B\ %e\,\ %Y %H:%M:%S", time());
   mysql_query("INSERT INTO trace_history3 (user,date,action,amount) VALUES ( '$log', '$entry_date', 'Bought $n', '$p' )")or die ( mysql_error());
   
header("Location: trancershop.php?g=$sel[0]");
}
else {
header("Location: trancershop.php?g=$s&alert=noechos");
}
}
else {
header("Location: today.php");
}
?>

 

What the code is supposed to do:

In short, it is a virtual transaction.

The item is removed from the sales table, item is added to buyer`s inventory, the amount of echos (currency) the seller marks the item for should be removed from buyer`s echos amount and put the amount in sales for the buyer to pick up.

 

What the code is currently doing:

It will remove the item from the sales table, it is entering the item into the buyer`s inventory, the amount is entered into sales for seller to pick up, however the amount is not being correctly removed from the buyer`s echos.

 

What I have done:

I`ve echo`ed out all the information and the information being transferred through the form for the transaction is correct and all of the info is being picked up by the code. I`ve re-written the line of codes involving the removal of the ehcos amount from the buyer`s amount and have two different results: 1) the buyer`s echos remain the same 2) the buyer`s echos change to the negative amount of what $p is instead of just simple subtraction

 

References:

The following line of code

   $_SESSION['echos'] = $echos = $echos + 10;
   mysql_query("UPDATE userdata SET echo_count='$echos' WHERE id='$logged' ") or die(mysql_error());

is used in another file where echos are being added to the user`s echos amount and this works perfectly fine. I post this because some people have issues with how I write the code for math calculations of the echos and claim it doesn`t work, however I have files where it does work, and this had worked for months.

 

Additional info:

$logged is defined in design.php which I am not posting because that is not the problem.

 

I think that`s all the info needed.

Link to comment
Share on other sites

I have found that including header.php made it work:

<title><? echo $Title ?></title>
<style type="text/css">
<!--
input { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; color: #B6ABCE; text-decoration: none; background-color: #000000; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px}
}
-->
</style>

<META NAME="keywords" CONTENT="online art gallery,art gallery,art,online art,online gallery,free online art gallery,drawings,literature,paintings,fiction,community art,digital art,traditional art,poetry,prose,applications,community,online community,secret,trance,photographs,photos,comics,anime,anthro,anthropomorphic,furry,furries,fantasy,horror,romance,adventure,action,macabre,animals,people,centaurs,unicorns,pegasus,mermaids,dragons,elves,japanese,wallpapers,pictures,image,images,free,artwork,illustrations,graphics,myths,mythology,gothic,games,online games,fantasy art,anime fantasy art,anime furry,anime fantasy,anime furries,anime illustrations,anime arts,pic art,anime illustration,draw art,anime gothic,anime dark,dark art,gothic art gallery,gothic art pictures,gothic art galleries,gothic artists,gothic artist,gothic fairy art,fairies,faeries,goth artist,goth art,goth artists,morbid art,vampire art,vampyr art,gothic pics,scary art,gothic fantasy,gothic anime,gothic drawing,dark gothic,dark goth,gothic death,gothic morbid,dark fantasy art,art sketches,anime original art,vampire fantasy art,vampire images,vampire pics,vampire drawings,vampire sketches,vampire anime,vampire drawing,vampire goth,vampire fantasy,vampire pic,pictures art,demons art,sketches art,vampire horror,pics art,secret trance, customize avatar, dolls">
<META NAME="description" CONTENT="Online community of artists and authors. Online art and literature galleries, customizable avatars, games and more available for free. Many different subjects and genres are available.">
<body bgcolor="746D84" text="B6ABCE" link="B6ABCE" vlink="B6ABCE" onLoad="if (self != top) top.location = self.location">
<link REL="SHORTCUT ICON" HREF="favicon.ico">

<table border=0 width=100%>
<tr>
<td>
<a href="today.php"><img src="banner2.png" border=0></a>
</table>
<?php
if ($site[1] == 0) {
?>
<? require_once "logged.php"; ?>
<?php
}
else {
if ($site[1] == 1){
	echo "<table border=0 width=100% bgcolor='000000'><tr><td background='$boxbanner'><b>Read-Only Mode</b>";
	echo "<tr><td background='$boxback'>";
	echo "Secret Trance is in read-only mode for maintenance. Check back in a few minutes.";
	echo "</table>";
}
}
?>

 

Though I don`t understand why not having header.php was preventing the code from operating.

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.