Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/11/2008, 12:02
lauchalp95
 
Fecha de Ingreso: julio-2006
Mensajes: 254
Antigüedad: 17 años, 10 meses
Puntos: 0
Error en sintaxis MYSQL

Bueno, el asunto es que deseo agregar lo que un usuario manda en un formulario al monto total del banco, y sacarlo de la billetera, ya cree el codigo, pero me lanza el error;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '9223372036854775807 SET = '9223372036854775807'' at line 1
¿Que error tengo en la sintaxis?
(No tiene nada que ver con el topico anterior, asi que por favor no lo borren ;))
Las lineas donde esta el codigo que lanza error es de la 119 a la 130
Código php:
Ver original
  1. <?php
  2. # FileName="Connection_php_mysql.htm"
  3. # Type="MYSQL"
  4. # HTTP="true"
  5. $hostname_TecnoPets = "mysql.webcindario.com";
  6. $database_TecnoPets = "*********";
  7. $username_TecnoPets = "*********";
  8. $password_TecnoPets = "*********";
  9. $TecnoPets = mysql_pconnect($hostname_TecnoPets, $username_TecnoPets, $password_TecnoPets) or trigger_error(mysql_error(),E_USER_ERROR);
  10. ?>
  11. <?php
  12. if (!isset($_SESSION)) {
  13. }
  14. $MM_authorizedUsers = "";
  15. $MM_donotCheckaccess = "true";
  16.  
  17. // *** Esto es para restringir el acceso a la pagina
  18. function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
  19.   // Por seguridad, primeramente, el visitante no podra entrar
  20.   $isValid = False;
  21.  
  22.   // La varable de sesion es como el usuario si el esta logeado
  23.   // Y sino, se queda en blanco.
  24.   if (!empty($UserName)) {
  25.     //
  26.     $arrUsers = Explode(",", $strUsers);
  27.     $arrGroups = Explode(",", $strGroups);
  28.     if (in_array($UserName, $arrUsers)) {
  29.       $isValid = true;
  30.     }
  31.     //
  32.     if (in_array($UserGroup, $arrGroups)) {
  33.       $isValid = true;
  34.     }
  35.     if (($strUsers == "") && true) {
  36.       $isValid = true;
  37.     }
  38.   }
  39.   return $isValid;
  40. }
  41.  
  42. $MM_restrictGoTo = "/logeo.php";
  43. if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
  44.   $MM_qsChar = "?";
  45.   $MM_referrer = $_SERVER['PHP_SELF'];
  46.   if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  47.   if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
  48.   $MM_referrer .= "?" . $QUERY_STRING;
  49.   $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  50.   header("Location: ". $MM_restrictGoTo);
  51.   exit;
  52. }
  53. ?>
  54. <?php
  55. if (!function_exists("GetSQLValueString")) {
  56. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  57. {
  58.   if (PHP_VERSION < 6) {
  59.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  60.   }
  61.  
  62.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  63.  
  64.   switch ($theType) {
  65.     case "text":
  66.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  67.       break;    
  68.     case "long":
  69.     case "int":
  70.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  71.       break;
  72.     case "double":
  73.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  74.       break;
  75.     case "date":
  76.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  77.       break;
  78.     case "defined":
  79.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  80.       break;
  81.   }
  82.   return $theValue;
  83. }
  84. }
  85.  
  86. $colname_dat = "-1";
  87. if (isset($_SESSION['MM_Username'])) {
  88.   $colname_dat = $_SESSION['MM_Username'];
  89. }
  90. mysql_select_db($database_TecnoPets, $TecnoPets);
  91. $query_dat = sprintf("SELECT * FROM tecnopoints WHERE usuario = %s", GetSQLValueString($colname_dat, "text"));
  92. $dat = mysql_query($query_dat, $TecnoPets) or die(mysql_error());
  93. $row_dat = mysql_fetch_assoc($dat);
  94. $totalRows_dat = mysql_num_rows($dat);
  95.  
  96. $colname_banco = "-1";
  97. if (isset($_SESSION['MM_Username'])) {
  98.   $colname_banco = $_SESSION['MM_Username'];
  99. }
  100. mysql_select_db($database_TecnoPets, $TecnoPets);
  101. $query_banco = sprintf("SELECT * FROM banco WHERE usuario = %s", GetSQLValueString($colname_banco, "text"));
  102. $banco = mysql_query($query_banco, $TecnoPets) or die(mysql_error());
  103. $row_banco = mysql_fetch_assoc($banco);
  104. $totalRows_banco = mysql_num_rows($banco);
  105. ?>
  106.  
  107. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  108. <html xmlns="http://www.w3.org/1999/xhtml">
  109. <head>
  110. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  111. <title>Documento sin título</title>
  112. <link href="/estilo.css" rel="stylesheet" type="text/css" />
  113. </head>
  114.  
  115. <body>
  116. <p>
  117. <?
  118. if($_POST[ag] > $row_dat[tp]) { echo " No tienes tantos TP ";  } else {
  119. $yu =  $row_dat[tp] - $_POST[ag];
  120. $ya =  $row_banco[tp] + $_POST[ag];
  121.  
  122. $montito = "UPDATE $row_dat[tp] SET = '$yu'";
  123. $banqi = "UPDATE  $row_banco[tp] SET  = '$ya'";
  124.  
  125. $ejecutomontito = mysql_query($montito) or die(mysql_error());
  126. $ejecutobanqi = mysql_query($banqi) or die(mysql_error());
  127. };
  128. ?>
  129.  
  130. </p>
  131. <p><a href="/index.php" target="_top">ACTUALIZAR DATOS</a></p>
  132. </body>
  133. </html>