Foros del Web » Programando para Internet » PHP »

Problemas con panel de insercion de datos

Estas en el tema de Problemas con panel de insercion de datos en el foro de PHP en Foros del Web. Saludos... ando aun con el tema de insertar usuarios en mi base de datos... en realidad quiero que me inserte mediente este panel los datos ...
  #1 (permalink)  
Antiguo 11/09/2007, 08:17
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Problemas con panel de insercion de datos

Saludos... ando aun con el tema de insertar usuarios en mi base de datos...
en realidad quiero que me inserte mediente este panel los datos d eunas tiendas divididas por sucursales... peeeeeeero el PKID deberia ser un campo oculto pues solo es un identificador... no me funciona no se q error tndre...

Código:
?php virtual('../Connections/basinger.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO sucursales (PKID, tienda, ciudad, ubicacion) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['PKID'], "int"),
                       GetSQLValueString($_POST['tienda'], "text"),
                       GetSQLValueString($_POST['ciudad'], "text"),
                       GetSQLValueString($_POST['ubicacion'], "text"));

  mysql_select_db($database_tiendas, $tiendas);
  $Result1 = mysql_query($insertSQL, $tiendas) or die(mysql_error());

  $insertGoTo = "cpanel2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO sucursales (PKID, tienda, ciudad, ubicacion) VALUES (%s, %s, %s, %s)",
                       GetSQLValueString($_POST['PKID'], "int"),
                       GetSQLValueString($_POST['tienda'], "text"),
                       GetSQLValueString($_POST['ciudad'], "text"),
                       GetSQLValueString($_POST['ubicacion'], "text"));

  mysql_select_db($database_basinger, $basinger);
  $Result1 = mysql_query($insertSQL, $basinger) or die(mysql_error());

  $insertGoTo = "cpanel2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

$colname_Recordset1 = "-1";
if (isset($_GET['PKID'])) {
  $colname_Recordset1 = $_GET['PKID'];
}
mysql_select_db($database_tiendas, $tiendas);
$query_Recordset1 = sprintf("SELECT * FROM sucursales WHERE PKID = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $basinger) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <table align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Tienda:</td>
      <td><input type="text" name="tienda" value="<?php echo $row_Recordset1['tienda']; ?>" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Ciudad:</td>
      <td><select name="ciudad">
        <option value="" >Seleccione un estado</option>
        <option value="" >Caracas</option>
        <option value="" >Valencia</option>
        <option value="" >Barquisimeto</option>
        <option value="" >San Cristobal</option>
        <option value="" >Maracaibo</option>
        <option value="" >Margarita</option>
      </select>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right" valign="top">Ubicación:</td>
      <td><textarea name="ubicacion" cols="50" rows="5"><?php echo $row_Recordset1['ubicacion']; ?></textarea>
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="Insert record" /></td>
    </tr>
  </table>
  <input type="hidden" name="PKID" value="" />
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
y me da estos errores...

Notice: Undefined variable: database_tiendas in c:\archivos de programa\easyphp1-8\www\basinger\cpanel\cpanel.php on line 10

Notice: Undefined variable: tiendas in c:\archivos de programa\easyphp1-8\www\basinger\cpanel\cpanel.php on line 0

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in c:\archivos de programa\easyphp1-8\www\basinger\cpanel\cpanel.php on line 0
Base de datos no seleccionada
  #2 (permalink)  
Antiguo 11/09/2007, 09:14
Avatar de mauled  
Fecha de Ingreso: marzo-2005
Ubicación: Cd. de México.
Mensajes: 3.001
Antigüedad: 19 años, 1 mes
Puntos: 33
Re: Problemas con panel de insercion de datos

Pues yo no veo que en ninguna parte inicilializes algunas de estas dos variables....
¿Te falto código por postear?

Saludillos.
  #3 (permalink)  
Antiguo 11/09/2007, 09:33
Avatar de Seppo  
Fecha de Ingreso: marzo-2005
Ubicación: Buenos Aires, Argentina
Mensajes: 1.284
Antigüedad: 19 años, 1 mes
Puntos: 17
Re: Problemas con panel de insercion de datos

¿Por qué no ponés el código de /basinger/cpanel/cpanel.php para ver que pasa?
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:36.