Tengo este codigo:
Código PHP:
<? **Archivo de conexion** ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_TecnoPets, $TecnoPets);
$query_tec = "SELECT * FROM tecnopoints";
$tec = mysql_query($query_tec, $TecnoPets) or die(mysql_error());
$row_tec = mysql_fetch_assoc($tec);
$totalRows_tec = mysql_num_rows($tec);
mysql_select_db($database_TecnoPets, $TecnoPets);
$query_usuaros = "SELECT * FROM usuarios";
$usuaros = mysql_query($query_usuaros, $TecnoPets) or die(mysql_error());
$row_usuaros = mysql_fetch_assoc($usuaros);
$totalRows_usuaros = mysql_num_rows($usuaros);
mysql_select_db($database_TecnoPets, $TecnoPets);
$query_banco = "SELECT * FROM banco";
$banco = mysql_query($query_banco, $TecnoPets) or die(mysql_error());
$row_banco = mysql_fetch_assoc($banco);
$totalRows_banco = mysql_num_rows($banco);
mysql_free_result($tec);
mysql_free_result($usuaros);
mysql_free_result($banco);
?>
<?
$restamonto = $_POST['ag'] - $row_tec['tp'];
$sumabanco = $_POST['ag'] + $row_banco['tp'];
if
($_POST[ag] > $row_tec['tp'])
{
echo "No hagas trampa. No puedes ingresar tantos TP sino los tienes...";
}
else
{
mysql_select_db($database_TecnoPets, $TecnoPets);
$sacardelmonto = "UPDATE tecnopoints SET tp = ' $restamonto ' WHERE usuario = '$_SESSION[MM_Username] ";
mysql_select_db($database_TecnoPets, $TecnoPets);
$agregaralbanco = "UPDATE banco SET tp = ' $sumabanco ' WHERE usuario = '$_SESSION[MM_Username] ";
echo "Se han sacado del monto total los np pedidos y se han agregado al monto del banco";
}
?>
Si quieren una vista mas real de lo que pasa, pueden registrarse ya y ir a banco y ahi agregar al banco algunos tecno points (puntos del sitio), para registrarse cuando entren vallan a Iniciar sesion de ahi a registro y de ahi pongan 'actualizar datos' y ahi vallan al banco, y desde ahi agregen y fijense.
Les agradeceria mucho la solucion
![borracho](http://static.forosdelweb.com/fdwtheme/images/smilies/borracho.png)