Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

Crear tabla

Estas en el tema de Crear tabla en el foro de Mysql en Foros del Web. Hola mis amigos. Es mi primera incursion en mySQL. Baje una aplicacion, donde necesita de una base de datos en este formato. Como no se ...
  #1 (permalink)  
Antiguo 29/05/2007, 18:54
Avatar de vec
vec
 
Fecha de Ingreso: junio-2001
Mensajes: 291
Antigüedad: 22 años, 10 meses
Puntos: 8
Pregunta Crear tabla

Hola mis amigos. Es mi primera incursion en mySQL. Baje una aplicacion, donde necesita de una base de datos en este formato.

Como no se bien del tema, no entiendo si crear la tabla debo tener un software como access, o se hace con una determinada extension.

La tabla qeu debo crear es la siguiente .. con las siguietnes caracteristicas.

CREATE TABLE guestbook (
ID int(5) NOT NULL auto_increment,
name text NOT NULL,
email text NOT NULL,
comments text NOT NULL,
time datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (ID)
)

Agradeceria que me den una guia. Gracias amigos
__________________
[email protected]
  #2 (permalink)  
Antiguo 30/05/2007, 09:05
Avatar de claudiovega  
Fecha de Ingreso: octubre-2003
Ubicación: Puerto Montt
Mensajes: 3.667
Antigüedad: 20 años, 6 meses
Puntos: 11
Re: Crear tabla

1) ¿Instalaste el servidor mysql? Si no lo haz instalado baja mysql e instálalo.

Lo puedes bajar desde:

http://dev.mysql.com/downloads/mysql/5.0.html#downloads

2) Puedes desde ahí bajar también las tools.

http://dev.mysql.com/downloads/gui-tools/5.0.html

Estas tools te permiten administrar el servidor y realizar gráficamente el trabajo sobre las bases de datos. MySql Administrator para crear bases de datos, tablas, usuarios,etc; MySql Query Browser para hacer consultas y ejecutar scripts.
  #3 (permalink)  
Antiguo 31/05/2007, 19:15
Avatar de vec
vec
 
Fecha de Ingreso: junio-2001
Mensajes: 291
Antigüedad: 22 años, 10 meses
Puntos: 8
Re: Crear tabla

Muchas gracias.... Ya pude hacerlo y crearlo.. ya lo subi a la web.. pero cuando deseo enviar los datos me da un mensaje de undefined.. porque???

el link es http://http://www.sos-designs.com/librovisitas.html

Gracias por cualqueir sugenrencia.
__________________
[email protected]
  #4 (permalink)  
Antiguo 01/06/2007, 10:36
Avatar de claudiovega  
Fecha de Ingreso: octubre-2003
Ubicación: Puerto Montt
Mensajes: 3.667
Antigüedad: 20 años, 6 meses
Puntos: 11
Re: Crear tabla

1) librovisitas es una pagina html, no un script php
2) undefined es un mensaje de flash al parecer.

Si quieres usar php en una pagina, el archivo debe ser con extension .php.

Bueno, estoy suponiendo que quieres usar php para acceder a mysql.
  #5 (permalink)  
Antiguo 01/06/2007, 10:40
Avatar de vec
vec
 
Fecha de Ingreso: junio-2001
Mensajes: 291
Antigüedad: 22 años, 10 meses
Puntos: 8
Re: Crear tabla

Uso un archivo PHP, el flash llama a este archivo y este archivo invoca a la BD... aca pongo el codigo...

<?
// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
$DBhost = "localhost"; // Database Server
$DBuser = "root"; // Database User
$DBpass = ""; // Database Pass
$DBName = "turorials"; // Database Name
$table = "guestbook"; // Database Table
$numComments = 10; // Number of Comments per page

// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// Part Two - Choose what action to perform
$action = $_GET['action'];

switch($action) {
case 'read' :
// Fetch all comments from database table
$sql = 'SELECT * FROM `' . $table . '`';
$allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
// Fetch page-wise comments from database table
$sql .= ' ORDER BY `times` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
// Generate Output for Flash to Read
print '&totalEntries=' . $numallComments . '&';
print "<br>&entries=";

if($numallComments == 0) {
print "No entries in the guestbook, as yet..";
} else {
while ($array = mysql_fetch_array($fewComments)) {
$name = mysql_result($fewComments, $i, 'name');
$email = mysql_result($fewComments, $i, 'email');
$comments = mysql_result($fewComments, $i, 'comments');
$times = mysql_result($fewComments, $i, 'times');

print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<br><b>Comments: </b>' . $comments . '<br><i>Date: ' . $times . '</i><br><br>';
$i++;
}
}
// Print this only when there aren't any more entries..
if($_GET['NumLow'] > $numallComments) {
print 'No More Entries!&';
}
break;

case 'write' :
// Recieve Variables From Flash
$name = ereg_replace("&", "%26", $_POST['yourname']);
$email = ereg_replace("&", "%26", $_POST['youremail']);
$comments = ereg_replace("&", "%26", $_POST['yourcomments']);
$submit = $_POST['submit'];

// Current system date in yyyy-mm-dd format
$submitted_on = date ("Y-m-d H:i:s",time());

// Check if its submitted from Flash
if($submit == 'Yes'){
// Insert the data into the mysql table
$sql = 'INSERT INTO ' . $table .
' (`ID`,
`name`,
`email`,
`comments`,
`times`
)
VALUES
(\'\','
. '\'' . $name . '\','
. '\'' . $email . '\','
. '\'' . $comments . '\','
. '\'' . $submitted_on . '\'
)';
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// If you want your script to send email to both you and the guest, uncomment the following lines of code
// Email Script Begin

/* <-- Remove this line
$MyName = "Superior Optimum Services, Corp.";
$MyEmail = "[email protected]";
$Subject = "$name has just signed your guestbook.";
$EmailBody = "Hello Mr/Mrs/Mss,\n$name has just signed your guestbook available at http://www.sos-designs.com. THe following were the details submitted into your guestbook:\n\nName: $name\nEmail: $email\nComment:\n$comments\n";

$EmailFooter = "~~~~~~~~~~~~~~~\nThe guestbook was signed by $name and thus this email got activated by $name from $REMOTE_ADDR from http://www.sos-designs.com\n~~~~~~~~~~~~~~~\nThank you,\nMr/Mrs/Mss Sumar";

$Message = $EmailBody.$EmailFooter;

mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
--> Remove this line */

// Email Script End

print "&gb_status=Thank you for signing our guestbook.&done=yes&";
return;
}
print "&_root.write.gb_status=Error!&";
break;
}
?>
__________________
[email protected]
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 14:01.