Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/03/2007, 11:09
Induma
 
Fecha de Ingreso: enero-2004
Ubicación: en mi casa
Mensajes: 29
Antigüedad: 20 años, 3 meses
Puntos: 1
Exclamación Re: seleccionar base de datos

basicamente por que no se mucho de estas cosas y como con el dreamweaver es asi de sencillito pues eso, que me resulto mas facil clonar las tablas y las paginas.
pero a la hora de realizar los registros me di cuenta del error, intente darle vueltas y no consegui nada, por eso he pedido ayuda
pongo la base de datos (las otras seis son iguales, pero con distinto nombre: pescados, ensaladas, ....):

Código:
#
# Estructura de tabla para la tabla `carnes`
#

DROP TABLE IF EXISTS `carnes`;
CREATE TABLE `carnes` (
  `categoria` varchar(255) NOT NULL default '',
  `nombre` varchar(255) NOT NULL default '',
  `ingredientes` longtext NOT NULL,
  `tiempo` varchar(255) NOT NULL default '',
  `imagen` varchar(255) NOT NULL default '',
  `receta` longtext NOT NULL
) TYPE=MyISAM;

#
# Volcar la base de datos para la tabla `carnes`
#
y aqui el codigo de la pagina de insertar los registros:

Código:
<?php require_once('../../Connections/recetas.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 carnes (nombre, ingredientes, tiempo, imagen, receta) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['nombre'], "text"),
                       GetSQLValueString($_POST['ingredientes'], "text"),
                       GetSQLValueString($_POST['tiempo'], "text"),
                       GetSQLValueString($_POST['imagen'], "text"),
                       GetSQLValueString($_POST['receta'], "text"));

  mysql_select_db($database_recetas, $recetas);
  $Result1 = mysql_query($insertSQL, $recetas) or die(mysql_error());

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

mysql_select_db($database_recetas, $recetas);
$query_carnes = "SELECT * FROM carnes";
$carnes = mysql_query($query_carnes, $recetas) or die(mysql_error());
$row_carnes = mysql_fetch_assoc($carnes);
$totalRows_carnes = mysql_num_rows($carnes);
?>
<style type="text/css">
<!--
.Estilo1 {
	color: #CC0000;
	font-weight: bold;
}
-->
</style>

<div align="center" class="Estilo1">
  <p>INSERTAR RECETA DE CARNES
</p>
  <p>&nbsp;  </p>
</div>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Nombre:</td>
      <td><input type="text" name="nombre" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Ingredientes:</td>
      <td><textarea name="ingredientes" cols="32"></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Tiempo:</td>
      <td><input type="text" name="tiempo" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Imagen:</td>
      <td><input type="text" name="imagen" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Receta:</td>
      <td><textarea name="receta" cols="32"></textarea></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Insertar registro"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
<?php
mysql_free_result($carnes);
?>
que solucion me podeis dar?
muchas gracias
un saludo

INDUMA