kostenloser Webspace werbefrei: lima-city


Anpassen von PHP Script mit Mysql Daten drin

lima-cityForumProgrammiersprachenPHP, MySQL & .htaccess

  1. Autor dieses Themas

    fitsein

    fitsein hat kostenlosen Webspace.

    Also mein Problem liegt in nachfolgendem Installationsscript. Eigentlich sollte ich es nur ins Französische übersetzen aber dafür hätte ich es am liebsten installiert um sicher zugehen dass auch wirklich alles 1:1 passt.

    Doch leider liessen sich die Daten beim Aufrufen des Installationsscripts nicht in der Datenbank erstellen worauf ich es manuell versucht habe und auch da gescheitert bin.

    Grund für mein Scheitern sind Fehler in der Syntaxe, welche ich auch mit dem aktuellen Handbuch nicht gefunden habe. Hoffe nun das mir hier jemand helfen kann z.B. dadurch dass er eine Möglichkeit weiss diese Datenbankanweisungen in gültige umzuwandeln.

    <?php
    
    /***********************************************************************
    
    Install script
    
    ***********************************************************************/
    
    if ( isset($send) )
    // We have already sent the admin data
    {
     require("common.php");
     // We make avaiable the database
     $db = new database()
    	or die("La base de datos está sobrecargada, por favor intentalo más tarde");
    
     echo "Eliminando las anteriores bases de datos si existieran<br><br>";
     $query = "DROP TABLE `League` , `Matches` , `Messages` , `Modules` , `Players` , `Teams` , `Users` ;";
     $db->doQuery ($query);
    
     echo "Creando las bases de datos...<br><br>";
    
     // Users Table
     $query = "CREATE TABLE Users (uname CHAR(16) NOT NULL, pass CHAR(50), team INT, admin BIT,";
     $query .= "email CHAR(30), language CHAR(5), skin CHAR(16), KEY(uname));";
     $db->doQuery ($query);
    
     $pass = md5($pass);
     $query = "INSERT INTO Users (uname, pass, admin, email, language, skin) VALUES ";
     $query .= "('$user', '$pass', '1', '', 'es', 'default');";
     $db->doQuery ($query);
    
     // Players table
     $query = "CREATE TABLE Players (id INT NOT NULL AUTO_INCREMENT, name CHAR(30), team INT, uname CHAR(16), defence INT(7),";
     $query .= " pass INT(7), shoot INT(7), keeping INT(7), endurance INT(7), physicalForm INT(7), weeksInjured INT UNSIGNED, matchesPlayed INT UNSIGNED, goals INT, KEY(id) );";
     $db->doQuery ($query);
    
    
     // Match table
     $query = "CREATE TABLE Matches (id INT NOT NULL AUTO_INCREMENT, home INT,";
     $query .= " away INT, played BIT, scoreHome INT, scoreAway INT, commentary LONGTEXT,";
     $query .= " week INT, KEY(id) );";
     $db->doQuery ($query);
    
    
     // Teams table
     $query = "CREATE TABLE Teams (id INT NOT NULL AUTO_INCREMENT, teamName CHAR(30),uname CHAR(16) NOT NULL,";
     $query .= " tactic CHAR(8),N1 INT, N2 INT, N3 INT, N4 INT, N5 INT, N6 INT, N7 INT, N8 INT, N9 INT,";
     $query .= " N10 INT, N11 INT, N12 INT, N13 INT, N14 INT, N15 INT,";
     $query .= " leaguePoints INT, KEY(id) );";
     $db->doQuery ($query);
    
    
     // League table
     $query = "CREATE TABLE League (id INT NOT NULL AUTO_INCREMENT, week INT, KEY(id));";
     $db->doQuery ($query);
    
     $query = "INSERT INTO League (id,week) VALUES ('1','0')";
     $db->doQuery ($query);
    
    
     // Modules table
     $query = "CREATE TABLE Modules (id CHAR(20) NOT NULL, name CHAR(30),";
     $query .= " type INT, KEY(id) );";
     $db->doQuery ($query);
    
     // Insert modules values
     $query = "INSERT INTO Modules (id, name, type) VALUES ('calendar',";
     $query .= " 'Calendario', 1)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('change_profile',";
     $query .= " 'Editar perfil', 1)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('roster',";
     $query .= " 'Alineacion', 2)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('next_week',";
     $query .= " 'Avanzar jornada', 0)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('add_user',";
     $query .= " 'Añadir usuario', 0)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('reset_league',";
     $query .= " 'Resetear liga', 0)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('standings',";
     $query .= " 'Clasificacion', 1)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('private_messages',";
     $query .= " 'Mensajes Privados', 1)";
     $db->doQuery ($query);
    
     $query = "INSERT INTO Modules (id, name, type) VALUES ('manage_users',";
     $query .= " 'Administrar usuarios', 0)";
     $db->doQuery ($query);
    
     // Private Messages Table
     $query = "CREATE TABLE Messages (id INT NOT NULL AUTO_INCREMENT, messagefrom CHAR(30),";
     $query .= " messageto CHAR(30), subject CHAR(50), body LONGTEXT, internal BIT,  KEY(id) );";
     $db->doQuery ($query);
    
    
     echo "Creación completa. Borra el archivo install.php y ya puedes entrar con tu nuevo usuario.";
     echo "¡Disfruta del juego!";
    }
    else
    {
     ?>
  2. Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!

    lima-city: Gratis werbefreier Webspace für deine eigene Homepage

  3. Versuch einmal, die querys einzeln zu umzunennen. Also anstatt von
    $query = '';
    $query = '';
    $query = '';
    machst du
    $query = '';
    $query2 = '';
    $query3 = '';
    Das hat bei mir auch sehr oft geholfen.
  4. Der Fehler wird vom ersten Query herrühren:

    DROP TABLE `League` , `Matches` , `Messages` , `Modules` , `Players` , `Teams` , `Users`;


    Hier sollen die genannten Tabellen erst einmal gelöscht werden. Sind diese jedoch nicht vorhanden, gibts nen Fehler. Stattdessen MUSS der Query so aussehen:

    DROP TABLE IF EXISTS `League` , `Matches` , `Messages` , `Modules` , `Players` , `Teams` , `Users`;


    However... Mir persönlich sind das zu viele Variablen. Ich würde es min. so machen:

    <?php
    
    /***********************************************************************
    
    Install script
    
    ***********************************************************************/
    
    if(isset($send)) {
    	// We have already sent the admin data
    	require("common.php");
    	// We make avaiable the database
    	$db = new database() or die("La base de datos está sobrecargada, por favor intentalo más tarde");
    
    	echo "Eliminando las anteriores bases de datos si existieran<br><br>";
    	$db->doQuery ("DROP TABLE IF EXISTS `League` , `Matches` , `Messages` , `Modules` , `Players` , `Teams` , `Users`;");
    	echo "Creando las bases de datos...<br><br>";
    
    	// League table
    	$db->doQuery ("CREATE TABLE IF NOT EXISTS `league` (`id` int(11) NOT NULL AUTO_INCREMENT, `week` int(11) DEFAULT NULL, KEY `id` (`id`));");
    	
    	// Insert league values
    	$db->doQuery ("INSERT INTO `league` (`id`, `week`) VALUES (1, 0);");
    
    	// Match table
    	$db->doQuery ("CREATE TABLE IF NOT EXISTS `matches` (`id` int(11) NOT NULL AUTO_INCREMENT, `home` int(11) DEFAULT NULL, `away` int(11) DEFAULT NULL, `played` bit(1) DEFAULT NULL, `scoreHome` int(11) DEFAULT NULL, `scoreAway` int(11) DEFAULT NULL, `commentary` longtext, `week` int(11) DEFAULT NULL, KEY `id` (`id`));");	
    	
    	// Private Messages Table
    	$db->doQuery ("CREATE TABLE IF NOT EXISTS `messages` (`id` int(11) NOT NULL AUTO_INCREMENT, `messagefrom` char(30) DEFAULT NULL, `messageto` char(30) DEFAULT NULL, `subject` char(50) DEFAULT NULL, `body` longtext, `internal` bit(1) DEFAULT NULL, KEY `id` (`id`));");	
    	
    	// Modules table
    	$db->doQuery ("CREATE TABLE IF NOT EXISTS `modules` (`id` char(20) NOT NULL, `name` char(30) DEFAULT NULL, `type` int(11) DEFAULT NULL, KEY `id` (`id`))");
    	
    	// Insert modules values
    	$db->doQuery ("INSERT INTO `modules` (`id`, `name`, `type`) VALUES ('calendar', 'Calendario', 1), ('change_profile', 'Editar perfil', 1), ('roster', 'Alineacion', 2), ('next_week', 'Avanzar jornada', 0), ('add_user', 'Añadir usuario', 0), ('reset_league', 'Resetear liga', 0), ('standings', 'Clasificacion', 1), ('private_messages', 'Mensajes Privados', 1), ('manage_users', 'Administrar usuarios', 0);");	
    	
    	// Players table
    	$db->doQuery ("CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` char(30) DEFAULT NULL, `team` int(11) DEFAULT NULL, `uname` char(16) DEFAULT NULL, `defence` int(7) DEFAULT NULL, `pass` int(7) DEFAULT NULL, `shoot` int(7) DEFAULT NULL, `keeping` int(7) DEFAULT NULL, `endurance` int(7) DEFAULT NULL, `physicalForm` int(7) DEFAULT NULL, `weeksInjured` int(10) unsigned DEFAULT NULL, `matchesPlayed` int(10) unsigned DEFAULT NULL, `goals` int(11) DEFAULT NULL, KEY `id` (`id`));");	
    	
    	// Teams table
    	$db->doQuery ("CREATE TABLE IF NOT EXISTS `teams` (`id` int(11) NOT NULL AUTO_INCREMENT, `teamName` char(30) DEFAULT NULL, `uname` char(16) NOT NULL, `tactic` char(8) DEFAULT NULL, `N1` int(11) DEFAULT NULL, `N2` int(11) DEFAULT NULL, `N3` int(11) DEFAULT NULL, `N4` int(11) DEFAULT NULL, `N5` int(11) DEFAULT NULL, `N6` int(11) DEFAULT NULL, `N7` int(11) DEFAULT NULL, `N8` int(11) DEFAULT NULL, `N9` int(11) DEFAULT NULL, `N10` int(11) DEFAULT NULL, `N11` int(11) DEFAULT NULL, `N12` int(11) DEFAULT NULL, `N13` int(11) DEFAULT NULL, `N14` int(11) DEFAULT NULL, `N15` int(11) DEFAULT NULL, `leaguePoints` int(11) DEFAULT NULL, KEY `id` (`id`));");	
    	
    	// Users Table
    	$db->doQuery ("CREATE TABLE IF NOT EXISTS `users` (`uname` char(16) NOT NULL, `pass` char(50) DEFAULT NULL, `team` int(11) DEFAULT NULL, `admin` bit(1) DEFAULT NULL, `email` char(30) DEFAULT NULL, `language` char(5) DEFAULT NULL, `skin` char(16) DEFAULT NULL, KEY `uname` (`uname`));");
    	
    	// Insert users values
    	$db->doQuery ("INSERT INTO `users` (`uname`, `pass`, `team`, `admin`, `email`, `language`, `skin`) VALUES ('".$user."', '".md5($pass)."', NULL, '1', '', 'es', 'default');");
    
    	echo "Creación completa. Borra el archivo install.php y ya puedes entrar con tu nuevo usuario. ¡Disfruta del juego!";
    }
    else
    {
    ?>


    Wobei sich die Frage stellt, ob es Sinn macht, für jeden Pups einen Query auszuführen. Letztlich reicht es nämlich so:

    <?php
    
    /***********************************************************************
    
    Install script
    
    ***********************************************************************/
    
    if(isset($send)) {
    	// We have already sent the admin data
    	require("common.php");
    	// We make avaiable the database
    	$db = new database() or die("La base de datos está sobrecargada, por favor intentalo más tarde");
    
    	echo "Eliminando las anteriores bases de datos si existieran<br><br>";
    	$db->doQuery ("DROP TABLE IF EXISTS `League`, `Matches`, `Messages`, `Modules`, `Players`, `Teams`, `Users`;");
    	echo "Creando las bases de datos...<br><br>";
    
    	// Run queries
    	$db->doQuery ("
    	CREATE TABLE IF NOT EXISTS `league` (`id` int(11) NOT NULL AUTO_INCREMENT, `week` int(11) DEFAULT NULL, KEY `id` (`id`));
    	
    	-- Insert league values
    	INSERT INTO `league` (`id`, `week`) VALUES (1, 0);
    
    	-- Match table
    	CREATE TABLE IF NOT EXISTS `matches` (`id` int(11) NOT NULL AUTO_INCREMENT, `home` int(11) DEFAULT NULL, `away` int(11) DEFAULT NULL, `played` bit(1) DEFAULT NULL, `scoreHome` int(11) DEFAULT NULL, `scoreAway` int(11) DEFAULT NULL, `commentary` longtext, `week` int(11) DEFAULT NULL, KEY `id` (`id`));
    	
    	-- Private Messages Table
    	CREATE TABLE IF NOT EXISTS `messages` (`id` int(11) NOT NULL AUTO_INCREMENT, `messagefrom` char(30) DEFAULT NULL, `messageto` char(30) DEFAULT NULL, `subject` char(50) DEFAULT NULL, `body` longtext, `internal` bit(1) DEFAULT NULL, KEY `id` (`id`));
    	
    	-- Modules table
    	CREATE TABLE IF NOT EXISTS `modules` (`id` char(20) NOT NULL, `name` char(30) DEFAULT NULL, `type` int(11) DEFAULT NULL, KEY `id` (`id`));
    	
    	-- Insert modules values
    	INSERT INTO `modules` (`id`, `name`, `type`) VALUES ('calendar', 'Calendario', 1), ('change_profile', 'Editar perfil', 1), ('roster', 'Alineacion', 2), ('next_week', 'Avanzar jornada', 0), ('add_user', 'Añadir usuario', 0), ('reset_league', 'Resetear liga', 0), ('standings', 'Clasificacion', 1), ('private_messages', 'Mensajes Privados', 1), ('manage_users', 'Administrar usuarios', 0);	
    	
    	-- Players table
    	CREATE TABLE IF NOT EXISTS `players` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` char(30) DEFAULT NULL, `team` int(11) DEFAULT NULL, `uname` char(16) DEFAULT NULL, `defence` int(7) DEFAULT NULL, `pass` int(7) DEFAULT NULL, `shoot` int(7) DEFAULT NULL, `keeping` int(7) DEFAULT NULL, `endurance` int(7) DEFAULT NULL, `physicalForm` int(7) DEFAULT NULL, `weeksInjured` int(10) unsigned DEFAULT NULL, `matchesPlayed` int(10) unsigned DEFAULT NULL, `goals` int(11) DEFAULT NULL, KEY `id` (`id`));
    	
    	-- Teams table
    	CREATE TABLE IF NOT EXISTS `teams` (`id` int(11) NOT NULL AUTO_INCREMENT, `teamName` char(30) DEFAULT NULL, `uname` char(16) NOT NULL, `tactic` char(8) DEFAULT NULL, `N1` int(11) DEFAULT NULL, `N2` int(11) DEFAULT NULL, `N3` int(11) DEFAULT NULL, `N4` int(11) DEFAULT NULL, `N5` int(11) DEFAULT NULL, `N6` int(11) DEFAULT NULL, `N7` int(11) DEFAULT NULL, `N8` int(11) DEFAULT NULL, `N9` int(11) DEFAULT NULL, `N10` int(11) DEFAULT NULL, `N11` int(11) DEFAULT NULL, `N12` int(11) DEFAULT NULL, `N13` int(11) DEFAULT NULL, `N14` int(11) DEFAULT NULL, `N15` int(11) DEFAULT NULL, `leaguePoints` int(11) DEFAULT NULL, KEY `id` (`id`));
    	
    	-- Users Table
    	CREATE TABLE IF NOT EXISTS `users` (`uname` char(16) NOT NULL, `pass` char(50) DEFAULT NULL, `team` int(11) DEFAULT NULL, `admin` bit(1) DEFAULT NULL, `email` char(30) DEFAULT NULL, `language` char(5) DEFAULT NULL, `skin` char(16) DEFAULT NULL, KEY `uname` (`uname`));
    	
    	-- Insert users values
    	INSERT INTO `users` (`uname`, `pass`, `team`, `admin`, `email`, `language`, `skin`) VALUES ('".$user."', '".md5($pass)."', NULL, '1', '', 'es', 'default');
    	");
    
    	echo "Creación completa. Borra el archivo install.php y ya puedes entrar con tu nuevo usuario. ¡Disfruta del juego!";
    }
    else
    {
    ?>
  5. Autor dieses Themas

    fitsein

    fitsein hat kostenlosen Webspace.

    Ich danke euch beiden für die Lösungswege.

    @fabo: Ich habe dem der das Script erstellt hat deinen 2.Vorschlag mal geschickt, sieht schlanker aus und hat direkt bei mir funktioniert.

    Problem gelöst, kann von mir aus geschlossen werden.
  6. Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!

    lima-city: Gratis werbefreier Webspace für deine eigene Homepage

Dir gefällt dieses Thema?

Über lima-city

Login zum Webhosting ohne Werbung!