Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Installazione DB

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2002
    Messaggi
    314

    Installazione DB

    Sto cercando di installare un DB contenuto in un CD allegato ad un manuale.
    Sulla mia macchina ho installato Apache, Mysql e PHP.

    Quando lancio in file che dovrebbe installare il DB mi restituisce questo errore.


    You don't have permission to access /book/install/method="get" on this server.
    Codice PHP:
    <form action = <? echo $REQUEST_URI?> method="get">

    qualcuno sa dirmi come risolvere questo problema
    felix

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2002
    Messaggi
    314

    Forse potrebbe tornare utile lo script per intero.
    Codice PHP:
    <?
    //script to install databases for php/mysql book
    //to_install is the name of the database
    //filename are in the form dbname.dump
    mysql_connect("localhost""nobody""") or die
        (
    "<h3>Before Installing your Databases you must have MySQL installed and provide a valid host,
    username, and password in line two of the install.dbs file.</h3>"
    );

    $all_dbs = array ("guestbook2k""catalog""discussion","netsloth""survey""tracking");

    if(isset(
    $submit))
    {
        
    $to_install = array();
        if(isset(
    $passed_dbs) && is_array($passed_dbs) && isset($install_all))
        {
            echo 
    "Let's try this again. This time, please select the
             databases you would like installed OR check Install All.
              Not both. Press the back button, please."
    ;
            exit;
        } elseif (isset(
    $passed_dbs) && is_array($passed_dbs))
        {
            
    $to_install $passed_dbs;
        } elseif (isset(
    $install_all))
        {
            
    $to_install $all_dbs;
        }
        else
        {
            echo 
    "Let's try this again. This time, please select the
             databases you would like installed OR check Install All.
              Press the back button, please."
    ;
            exit;
        }
    //    $path = $DOCUMENT_ROOT . "/book/install/";
        
    foreach($to_install as $dbname)
        {
            
    //create and slect database
            
    mysql_query("drop database if exists $dbname") or die 
                (
    mysql_error() . "Could not drop database $dbname ");
            
    mysql_query("create database $dbname") or die 
                (
    mysql_error() . "Could not create database $dbname ");
            
    mysql_select_db($dbname);

            
    //files will come in the form dbname.dump
            //$file_to_parse = $path . $dbname . ".dump";
            
    $file_to_parse $dbname ".dump";
            if (!
    file_exists($file_to_parse))
            {
                echo 
    "Could not find '$file_to_parse'. Are your files placed properly? Please check";
                exit;
            }
            if (!
    $fp fopen($file_to_parse"r")) 
            {
                echo 
    "Read of $file_to_parse failed. Please check permissions.";
                exit;
            }
            
    $contents fread($fpfilesize ($file_to_parse));
            
    fclose($fp);
            
    //parse out drop, create, and insert statments
            
    preg_match_all("/(DROP TABLE.*?);/s"$contents$drop_statements);
            
    preg_match_all("/(CRE.*?);/s"$contents$create_statements);
            
    preg_match_all("/(INSER.*?);[\n\r]/s"$contents$insert_statements);
            
            foreach(
    $drop_statements[1] as $query)
            {
                
    mysql_query($query) or die
                    (
    mysql_error(). " drop table failed: $query.");
            } 

            foreach(
    $create_statements[1] as $query)
            {
                
    mysql_query($query) or die
                    (
    mysql_error(). " create table failed: $query.");
            } 

            foreach(
    $insert_statements[1] as $query)
            {
                
    mysql_query($query) or die
                    (
    mysql_error() . "insert failed: $query.");
            } 
            echo 
    "database \"$dbname\" successfully created.
    \n"
    ;
        }
        
    }
    else
    {
    ?>

    <h2>Welcome to the Applications for MySQL/PHP Applications Book</h2>



    If you are seeing this, you have PHP and MySQL installed and talking to each other. Cool</p>



    To get the applications working, you first need to install the databases with the sample data. Below
    please choose the databases you would like installed. Choose the individual databases or mark Install
    ALL.</p>



    [b]NOTE: If you have databases by the same name on your MySQL server they will be
    deleted! Beware.[/b]</p>



    Databases to install:</p>
    <form action = <? echo $REQUEST_URI?> method="get">
        <?
        
    foreach($all_dbs as $dbname){
            echo 
    "<input type=\"checkbox\" name=\"passed_dbs[]\" value=\"$dbname\">$dbname
    \n"
    ;
        }
        
    ?>
        
     
        <input type="checkbox" name="install_all" value="yes">Install All

        <input type="submit" name="submit" value="Submit">
    </form>

    <? ?>
    felix

  3. #3
    Utente di HTML.it L'avatar di SMASH
    Registrato dal
    Jun 2001
    Messaggi
    952
    Ma devi creare le tabelle del DB???
    Se sì, prendi il file .sql ed usa il phpmyadmin per creare il DB.
    .::Un consiglio può essere buono, ma tu ragiona da solo::.

  4. #4
    Utente di HTML.it
    Registrato dal
    Nov 2002
    Messaggi
    314
    Grazie per il consiglio.
    Ma non devo creare le tabelle devo creare il db così come proposto dalo scrip per poi eseguire gli esercizi del manuale
    felix

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2002
    Messaggi
    314
    felix

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.