• Home
  • Forum
  • Fare Web
  • PHP

Inserimento dati a cascata

  • Creatore Discussione Creatore Discussione Alex_70
  • Data di inizio Data di inizio 25 Apr 2020
Prec.
  • 1
  • 2
  • 3
  • 4
  • …
  • 11
Succ.
Primo Prec. 2 di 11 Succ. Ultimo

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #21
marino51 ha scritto:
a che serve, mi sembra non sia utile alla gestione dei film ....
Clicca per allargare...

per la trama, in questo modo viene formattata in modo corretto

se prendo i dati da un sito (imdb) faccio copia e incolla e viene come l'originale
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #22
questa é la modifica per avere html con all'interno echo delle variabili php

dimmi quale versione tieni, se la prima con un'unica echo
o questa seconda ( sostituisci dalla riga fino in fondo )
PHP:
        $opt .= "<option" . $selected . " value='" . $i . "'>" . $incollection[$i] . "</option>";
    }
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>

    <title><?php echo $set['Title']; ?></title>
  </head>
  <body <?php echo $set['FirstField']; ?>>


<div class='form-group'>

  <center><h1><span class='infob-pagetype'>inserisci dati</span></h1></center>

  <form name='filmForm' method='POST' action='<?php echo $set['script']; ?>'>

    <table id='biographyTable' border='0' cellspacing='0' cellpadding='0' width='100%'>
      <tbody>
        <tr>
          <td class='paramname'>
            <b>Title:</b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='movie_title' id='movie_title' size='100' value='<?php echo $row['movie_title']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Also Known As:</b>
          </td>
          <td class='paramvalue'>
            <textarea name='also_known' id='also_known' size='50'  style='width: 98%' value='<?php echo $row['also_known']; ?>'></textarea>
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Year: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='year' id='year' size='10' value='<?php echo $row['year']; ?>' />
          </td>
        </tr>
        <tr>
        <tr>
          <td class='paramname'>
            <b>Minutes: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='minutes' id='minutes' size='10' value='<?php echo $row['minutes']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Distributor: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='distributor' id='distributor' size='100' value='<?php echo $row['distributor']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Studio: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='studio' id='studio' size='100' value='<?php echo $row['studio']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Release Date: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='release_data' id='release_data' size='15' value='<?php echo $row['release_data']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>In Collection: </b> (<b><font color='red'>selezionare il valore</font></b>)
          </td>
          <td class='paramvalue'>
            <select name='incollection', id='incollection'><?php echo $opt; ?></select>
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Synopsis: </b>
          </td>
          <td class='paramvalue'>
            <textarea name='synopsis' id='editor1' rows='10' cols='80' value='<?php echo $row['synopsis']; ?>'></textarea>
          </td>
        </tr>
<!--
        <tr>
          <td class='paramname'>
            <b>Status:</b> (<b><font color='red'>Active, Retired, Dead</font></b>)
          </td>
          <td class='paramvalue'>
            <input type='text' name='status' id='status' value='<?php echo $row['status']; ?>' />
          </td>
        </tr>
-->
        <tr>
          <td class='paramvalue-footer center' colspan='2'>
            <br />
            <input type='submit' name='inserisci' id='inserisci' value='inserisci'>
            &nbsp;<br />
            &nbsp;<br />
          </td>
        </tr>
      </tbody>
    </table>
  </form>
  <div class='col-sm-10 col-sm-offset-2'><h2><?php echo $message; ?></h2></div>
</div>
</body>
</html>
<?php
}
?>
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #23
corretta
PHP:
<div class='col-sm-10 col-sm-offset-2'><h2><?php echo $message; ?></h2></div>
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #24
preferisco quest'ultima il codice e' piu' leggibile (per me)
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #25
ho notato una cosa,
se inserisco un dato e clicco su submit mi visualizza i dati a schermo,
ma se faccio un refresh della pagina i dati trasmessi non spariscono, rimane questo

Codice:
lo script é chiamato dopo un submit

invece se richiamo la pagina mi visualizza questo

Codice:
lo script é chiamato per un nuovo inserimento
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #26
ho inserito il CKeditor, ma i dati non vengono passati nella query

PHP:
<tr>
          <td class='paramname'>
            <b>Synopsis: </b>
          </td>
          <td class='paramvalue'>
            <textarea name='synopsis' id='editor1' rows='10' cols='80' value='<?php echo $row['synopsis']; ?>'></textarea>
          </td>
        </tr>
        
        <!-- ckeditor(se ne metti piu di uno cambia textarea type="text" id="xxxxxxx" e replace('xxxxxxx', ) -->

        <script src="ckeditor/ckeditor.js"></script>


        <script>
            CKEDITOR.replace('editor1', {
                extraPlugins: 'colorbutton,colordialog'
            });
        </script>
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #27
Alex_70 ha scritto:
ma se faccio un refresh della pagina i dati trasmessi non spariscono, rimane questo
Clicca per allargare...
sono echo inseriti nel codice per farti capire la strada che fa, puoi commentarli entrambi

potresti completare la funzione aggiornaDB
inserendo ciò che serve per soddisfare i punti nel commento
e postando la sola funzione quando hai fatto.
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #28
Alex_70 ha scritto:
ho inserito il CKeditor, ma i dati non vengono passati nella query
Clicca per allargare...

hai controllato se il
<script src="ckeditor/ckeditor.js"></script>
viene caricato ?
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #29
si, lo script e' nella cartella e funziona, lo testato con un altro codice modifica.php
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #30
con lo script così modificato, sono attive le funzioni cerca, inserisci, modifica ed elimina

manca la gestione del db, se la vuoi inserire, io non ho mysql

prova ad eseguire lo script e vedi come cambiano i bottoni e le query che ti compaiono in alto allo schermo

lo script é in due parti perché da errore MrWebmaster

PHP:
<?php
$set['script']     = $_SERVER['PHP_SELF'];
$set['Title']      = "I miei film";
$set['FirstField'] = "onload='document.filmForm.movie_title.focus()'";

$message = "";

if (empty($_POST))
{
    inizializzaVariabili();    // lo script é allo stato iniziale o al termine di una azione
}
else
{
    leggiPost();               // lo script é chiamato dopo un submit

    validaForm();

    if ( empty($message) ) aggiornaDB($row['azione']);
}
displayForm($row['azione']);
die;

function inizializzaVariabili()
{
    global $row;

    $row['azione']       = "";

    $row['filmID']       = "";
    $row['movie_title']  = "";
    $row['also_known']   = "";
    $row['year']         = "";
    $row['minutes']      = "";
    $row['distributor']  = "";
    $row['studio']       = "";
    $row['release_data'] = "";
    $row['incollection'] = "0";
    $row['synopsis']     = "";
}

function leggiPost()
{
    global $row;

    $row['azione']       = addslashes($_POST['submit']);

    $row['filmID']       = addslashes($_POST['filmID']);
    $row['movie_title']  = addslashes($_POST['movie_title']);
    $row['also_known']   = addslashes($_POST['also_known']);
    $row['year']         = addslashes($_POST['year']);
    $row['minutes']      = addslashes($_POST['minutes']);
    $row['distributor']  = addslashes($_POST['distributor']);
    $row['studio']       = addslashes($_POST['studio']);
    $row['release_data'] = addslashes($_POST['release_data']);
    $row['incollection'] = addslashes($_POST['incollection']);
    $row['synopsis']     = addslashes($_POST['synopsis']);
}

function validaForm()
{
    global $row, $message;

    // qui vanno fatti i controlli dei dati inseriti

    if( $row['azione'] != "inserisci"
    and $row['azione'] != "modifica"
    and $row['azione'] != "elimina"
    and $row['azione'] != "cerca" )
    {
        $message = "ERRORE : non riconosco l'azione da compiere";
        return;
    }

    if( $row['azione'] == "cerca" and empty($row['filmID']) )
    {
        $row['azione'] = "";
        $message = "ERRORE : devi indicare il file ID";
        return;
    }

    // $message = "NON HO FATTO ALTRI CONTROLLI";
}

function aggiornaDB($azione = "")
{
    global $row, $message;

    // qui si aggiorna il db,
    // 1) apre la connessione
    // 2) inserisce/modifica il film
    // 3) verifica che sia stato inserito/aggiornato il film
    // 4) chiude la connessione

    switch ($azione)
    {
        case "inserisci":
            $sql = "INSERT INTO film(movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis) VALUES ("
                 . "  '" . $row['movie_title']  . "'"
                 . ", '" . $row['also_known']   . "'"
                 . ", '" . $row['year']         . "'"
                 . ", '" . $row['minutes']      . "'"
                 . ", '" . $row['distributor']  . "'"
                 . ", '" . $row['studio']       . "'"
                 . ", '" . $row['release_data'] . "'"
                 . ", '" . $row['incollection'] . "'"
                 . ", '" . $row['synopsis']     . "'"
                 . "  )";
        break;

        case "modifica":
            $sql = "UPDATE film SET"
                 . "  movie_title='"  . $row['movie_title']  . "'"
                 . ", also_known='"   . $row['also_known']   . "'"
                 . ", year='"         . $row['year']         . "'"
                 . ", minutes='"      . $row['minutes']      . "'"
                 . ", distributor='"  . $row['distributor']  . "'"
                 . ", studio='"       . $row['studio']       . "'"
                 . ", release_data='" . $row['release_data'] . "'"
                 . ", incollection='" . $row['incollection'] . "'"
                 . ", synopsis='"     . $row['synopsis']     . "'"
                 . "  WHERE filmID='" . $row['filmID']       . "'";
            break;

        case "elimina":
            $sql = "DELETE FROM film"
                 . "  WHERE filmID='" . $row['filmID']. "'";
            break;

        case "cerca":
            $sql = "SELECT  filmID, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
                 . "  WHERE filmID='" . $row['filmID'] . "'";

            $row['filmID']       = "1";    // simula la lettura del database valorizzado l'array $row
            $row['movie_title']  = "movie_title";
            $row['also_known']   = "also_known";
            $row['year']         = "year";
            $row['minutes']      = "minutes";
            $row['distributor']  = "distributor";
            $row['studio']       = "studio";
            $row['release_data'] = "release_data";
            $row['incollection'] = "1";
            $row['synopsis']     = "synopsis";

            echo $sql . "<br />";
            return;                   
            break;

        default:
            $message = "ERRORE : aggiornaDB azione non riconosciuta";
            break;
    }
    echo $sql . "<br />";

    $query = 1;  //$query = mysql_query( $sql );

    if( $query )
    {
        inizializzaVariabili();

        $message = "Congratulazioni! Dati inseriti.";
    }
    else
    {
        $message = "Attenzione : Dati non inseriti!";
    }
}
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #31
PHP:
function displayForm($azione = "")
{
    global $row, $set, $message;

    // gestisci bottoni
    if ( $azione == "cerca" )
    {
        $btn = "<input type='submit' name='submit' value='modifica' />"
             . "<input type='submit' name='submit' value='elimina' />";
    }
    else
    {
        $btn = "<input type='submit' name='submit' value='inserisci' />"
             . "<input type='submit' name='submit' value='cerca' />";
    }

    // valorizza la select "incollection"
    $opt = "";
    $incollection = array( 0 => 'scegli uno stato', 1 => 'Yes', 2 => 'No' );  // possible options for career status
    for( $i=0; $i < count($incollection); $i++ )
    {
        $selected = $i == $row['incollection'] ? ' selected' : '';
        $opt .= "<option" . $selected . " value='" . $i . "'>" . $incollection[$i] . "</option>";
    }
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1'>

    <title><?= $set['Title']; ?></title>
  </head>
  <body <?= $set['FirstField']; ?>>


<div class='form-group'>

  <center><h1><span class='infob-pagetype'>inserisci dati</span></h1></center>

  <form name='filmForm' method='POST' action='<?= $set['script']; ?>'>

    <table id='biographyTable' border='0' cellspacing='0' cellpadding='0' width='100%'>
      <tbody>
        <tr>
          <td class='paramname'>
            <b>film ID:</b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='filmID' id='filmID' size='10' value='<?= $row['filmID']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Title:</b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='movie_title' id='movie_title' size='100' value='<?= $row['movie_title']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Also Known As:</b>
          </td>
          <td class='paramvalue'>
            <textarea name='also_known' id='also_known' size='50'  style='width: 98%'><?= $row['also_known']; ?></textarea>
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Year: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='year' id='year' size='10' value='<?= $row['year']; ?>' />
          </td>
        </tr>
        <tr>
        <tr>
          <td class='paramname'>
            <b>Minutes: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='minutes' id='minutes' size='10' value='<?= $row['minutes']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Distributor: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='distributor' id='distributor' size='100' value='<?= $row['distributor']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Studio: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='studio' id='studio' size='100' value='<?= $row['studio']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Release Date: </b>
          </td>
          <td class='paramvalue'>
            <input type='text' name='release_data' id='release_data' size='15' value='<?= $row['release_data']; ?>' />
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>In Collection: </b> (<b><font color='red'>selezionare il valore</font></b>)
          </td>
          <td class='paramvalue'>
            <select name='incollection', id='incollection'><?= $opt; ?></select>
          </td>
        </tr>
        <tr>
          <td class='paramname'>
            <b>Synopsis: </b>
          </td>
          <td class='paramvalue'>
            <textarea name='synopsis' id='editor1' rows='10' cols='80'><?= $row['synopsis']; ?></textarea>
          </td>
        </tr>
<!--
        <tr>
          <td class='paramname'>
            <b>Status:</b> (<b><font color='red'>Active, Retired, Dead</font></b>)
          </td>
          <td class='paramvalue'>
            <input type='text' name='status' id='status' value='<?= $row['status']; ?>' />
          </td>
        </tr>
-->
        <tr>
          <td class='paramvalue-footer center' colspan='2'>
            <br />
            <?= $btn; ?>
            &nbsp;<br />
            &nbsp;<br />
          </td>
        </tr>
      </tbody>
    </table>
  </form>
  <div class='col-sm-10 col-sm-offset-2'><h2><?= $message; ?></h2></div>
</div>

<script src="https://cdn.ckeditor.com/ckeditor5/18.0.0/classic/ckeditor.js"></script>
<script> CKEDITOR.replace('editor1', { extraPlugins: 'colorbutton,colordialog' });</script>

</body>
</html>
<?php
}
?>
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #32
rimane aperto un particolare che lascio a te chiudere,
dopo cerca, quando ci sono i bottoni "modifica" ed "elimina" deve essere utilizzato l' ID restituito dalla select altrimenti se viene modificato il valore del form, si agisce sull' ID inserito successivamente
é facile da gestire, si può mettere un nuovo campo ID "hidden" nel form dove memorizzare l'ID "vero" ed utilizzarlo per le gestioni sopraddette

questo é l'aggiornamento del db con le chiamate mysql
PHP:
function aggiornaDB($azione = "")
{
    global $row, $message;

    $servername = "localhost";
    $username   = "username";
    $password   = "password";
    $dbname     = "myDB";
    $conn = new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_errno) { $message = "ERRORE : connessione al db fallita, " . $conn->connect_error; return; }

    switch ($azione)
    {
        case "inserisci":
            $sql = "INSERT INTO film(movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis) VALUES ("
                 . "  '" . $row['movie_title']  . "'"
                 . ", '" . $row['also_known']   . "'"
                 . ", '" . $row['year']         . "'"
                 . ", '" . $row['minutes']      . "'"
                 . ", '" . $row['distributor']  . "'"
                 . ", '" . $row['studio']       . "'"
                 . ", '" . $row['release_data'] . "'"
                 . ", '" . $row['incollection'] . "'"
                 . ", '" . $row['synopsis']     . "'"
                 . "  )";
        break;

        case "modifica":
            $sql = "UPDATE film SET"
                 . "  movie_title='"  . $row['movie_title']  . "'"
                 . ", also_known='"   . $row['also_known']   . "'"
                 . ", year='"         . $row['year']         . "'"
                 . ", minutes='"      . $row['minutes']      . "'"
                 . ", distributor='"  . $row['distributor']  . "'"
                 . ", studio='"       . $row['studio']       . "'"
                 . ", release_data='" . $row['release_data'] . "'"
                 . ", incollection='" . $row['incollection'] . "'"
                 . ", synopsis='"     . $row['synopsis']     . "'"
                 . "  WHERE filmID='" . $row['filmID']       . "'";
            break;

        case "elimina":
            $sql = "DELETE FROM film"
                 . "  WHERE filmID='" . $row['filmID']. "'";
            break;

        case "cerca":
            $sql = "SELECT  filmID, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
                 . "  WHERE filmID='" . $row['filmID'] . "'";
            break;

        default:
            $message = "ERRORE : aggiornaDB azione non riconosciuta";
            return;
            break;
    }
    echo $sql . "<br />";

    if ( !$conn->query($sql) ) { $message = "ERRORE : aggiornaDB errore nella query, " . $conn->error; return; }

    if ($azione == "cerca")
    {
        $row = $conn->fetch_assoc();
    }
    else
    {
        inizializzaVariabili();

        $message = "Congratulazioni, il database é stato aggiornato.";
    }
    $conn->close();
}

ps, questo codice NON è provato, non avendo mysql disponibile
 
Ultima modifica: 26 Apr 2020

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #33
dunque ho inserito la parte del codice relativo alla connessione al database,

prima ho sostituito filmID con il campo corretto film_id


ci sono dei problemi

1)

errore nel database anche se i dati vengono inseriti lo stesso

PHP:
Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'exadmin'@'localhost' (using password: NO) in E:\OSPanel\domains\localhost\cinema\00inserisci_film.php on line 95

INSERT INTO film(movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis) VALUES ( 'Test movie per Alex 2', '', '', '', '', '', '', '0', 'test' )

line 95
PHP:
$conn = new mysqli($host, $user, $password, $db);

2)

nel database e' presente una chiave univoca per evitare duplicati

PHP:
ERRORE : aggiornaDB errore nella query, Duplicate entry 'Test movie per Alex 2-0000' for key 'unique_index'

si potrebbe gestire questo errore con un messaggio che il film esiste gia'


3)

CKEDITOR non e' visibile in synopsis anche se il dato viene inserito lo stesso


4)

non ho capito il campo film_id in alto, cosa serve?






grazie ancora per il tuo grandissimo aiuto

adesso se aggiustiamo gli errori sopra si puo' completare con la relazione film_attori
 
Ultima modifica: 28 Apr 2020

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #34
scoperto l'errore al database nella linea 95

PHP:
$conn = new mysqli($host, $user, $password, $db);

linea 93

PHP:
$pass = 'expass';

e bastato sostituire $password con $pass
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #35
questa é l'ultima versione, trovi un nuovo bottone "rinuncia" e il campo ID bloccato per "modifica" ed "elimina"
ho cambiato il nome id
 

Allegati

  • archivioFilm.zip
    archivioFilm.zip
    2,8 KB · Visite: 330

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #36
aggiornato, ma la ricerca per id non va' ,

continuo a non capire perche' ricercare per id e non per movie_title

 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #37
Alex_70 ha scritto:
Access denied for user 'exadmin'@'localhost' (
Clicca per allargare...
ACCESSO NEGATO, per quell'utente, non é un problema dello script ...
e non avendo mysql non ti so aiutare, apri una nuova discussione specifica sull'argomento

Alex_70 ha scritto:
ERRORE : aggiornaDB errore nella query, Duplicate entry 'Test movie per Alex 2-0000' for key 'unique_index'
Clicca per allargare...
deve essere inserito il controllo nella function validaForm, qual'é la colonna su cui vi é la chiave univoca ?

Alex_70 ha scritto:
non ho capito il campo film_id in alto, cosa serve?
Clicca per allargare...
é la chiave su cui viene fatta la ricerca per poi andare in modifica o eliminazione
viene gestita una sola riga di ritorno dal db nella funzione cerca
 

marino51

Utente Attivo
28 Feb 2013
3.205
207
63
Lombardia
  • 26 Apr 2020
  • #38
Alex_70 ha scritto:
aggiornato, ma la ricerca per id non va'
Clicca per allargare...
io non sono davanti al tuo pc, se mi dici perché non va posso cercare di capire
altrimenti al non va, di solito rispondo
je souis desolé !
 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #39
1) per errore database ho risolto

2) ricerca per id,

ERRORE : aggiornaDB, errore nella query, You have an error in your SQL syntax


PHP:
case "cerca":
            $sql = "SELECT  film_id, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
                 . "  WHERE film_id='" . $row['film_id'] . "'";

ho il sospetto che manca qualcosa, dovrebbe essere cosi, o mi sbaglio

PHP:
$sql = "SELECT FROM Film


3) la chiave univoca si trova nella tabella film nei campi movie_title year


 

Alex_70

Utente Attivo
13 Nov 2018
371
14
18
HELL
  • 26 Apr 2020
  • #40
ecco la query eseguita su phpmyadmin completata con successo



quella attuale mi da errore

PHP:
$sql = "SELECT * FROM 'film' film_id, movie_title, also_known, year, minutes, distributor, studio, release_data, incollection, synopsis"
                 . "  WHERE film_id='" . $row['film_id'] . "'";

ma se provo ad inserire questo nel codice ricevo anche errore


PHP:
case "cerca":
            $sql = "SELECT * FROM film"
                 . "  WHERE film_id='" . $row['film_id'] . "'";
            break;


PHP:
SELECT * FROM film WHERE film_id='508'

PHP:
Fatal error: Call to undefined method mysqli::fetch_assoc() in E:\OSPanel\domains\localhost\cinema\archivioFilm.php on line 165

line 165

PHP:
 $row = $conn->fetch_assoc();
 
Ultima modifica: 26 Apr 2020
Prec.
  • 1
  • 2
  • 3
  • 4
  • …
  • 11
Succ.
Primo Prec. 2 di 11 Succ. Ultimo
Devi accedere o registrarti per poter rispondere.

Discussioni simili

L
inserimento form dati multipli ?
  • luigithen
  • 13 Mag 2021
  • PHP
Risposte
0
Visite
1K
PHP 13 Mag 2021
luigithen
L
J
Form inserimento dati in database
  • jerweb
  • 29 Gen 2021
  • Ajax
Risposte
1
Visite
4K
Ajax 5 Feb 2021
_SAGO
A
Inserimento dati nel database tramite form + altre operazioni
  • AndreaBet
  • 5 Giu 2020
  • PHP
Risposte
18
Visite
2K
PHP 5 Giu 2020
AndreaBet
A
T
Da xsd a xml ed inserimento dati in excel
  • tappa81
  • 23 Apr 2020
  • XML
Risposte
0
Visite
2K
XML 23 Apr 2020
tappa81
T
S
[PHP] email con inserimento dati nel database
  • sal88
  • 23 Nov 2019
  • PHP
  • 2
Risposte
23
Visite
4K
PHP 27 Nov 2019
Max 1
G
[Javascript] Errore inserimento dati Backend Node.js e workbench
  • giorgio85
  • 8 Ott 2019
  • Javascript
Risposte
1
Visite
1K
Javascript 28 Ott 2019
macus_adi
B
  • Bloccata
[PHP] Creare PDF dopo inserimento dati form
  • bipolare75
  • 28 Set 2019
  • PHP
Risposte
4
Visite
4K
PHP 28 Set 2019
Max 1
E
Inserimento dati da PHP in tabella MySQL
  • etto.demu
  • 1 Giu 2019
  • PHP
Risposte
5
Visite
3K
PHP 3 Giu 2019
zorro
E
Form inserimento dati con JavaScript
  • Emidio
  • 9 Mar 2019
  • Javascript
Risposte
0
Visite
2K
Javascript 9 Mar 2019
Emidio
E
K
[PHP] Inserimento dati database con postgres
  • keyz23
  • 3 Ott 2018
  • PHP
Risposte
2
Visite
2K
PHP 3 Ott 2018
keyz23
K
K
[PHP + MYSQL ] Inserimento dati in database da form dinamico
  • keyz23
  • 13 Set 2018
  • PHP
Risposte
13
Visite
12K
PHP 11 Ott 2019
marino51
M
Inserimento dati checkbox multipli in db da ajax a php
  • migo80
  • 23 Apr 2018
  • PHP
Risposte
1
Visite
2K
PHP 23 Apr 2018
migo80
M
M
[PHP] errore in semplie form inserimento dati
  • maxdp
  • 13 Nov 2016
  • PHP
Risposte
7
Visite
2K
PHP 18 Nov 2016
maxdp
M
S
[PHP] Inserimento dati su tabelle collegate 1-m
  • solari77
  • 6 Ott 2016
  • PHP
Risposte
17
Visite
4K
PHP 17 Ott 2016
borgo italia
M
[PHP] controllo inserimento dati un un form
  • MoPa
  • 4 Ago 2016
  • PHP
Risposte
4
Visite
6K
PHP 7 Lug 2018
Max 1
[PHP] Generare file pdf con inserimento dati
  • cris8380
  • 10 Giu 2016
  • PHP
  • 2
Risposte
34
Visite
12K
PHP 18 Giu 2016
cris8380
Inserimento dei dati automatici mediante numero di tessera.
  • cris8380
  • 8 Giu 2016
  • PHP
  • 2
Risposte
21
Visite
3K
PHP 9 Giu 2016
cris8380
G
mysql - problemi inserimento dati nel database, consigli.
  • giorgio85
  • 25 Mag 2016
  • MySQL
Risposte
3
Visite
2K
MySQL 26 Mag 2016
marino51
J
Inserimento dati in db da due o più form
  • jumpy83
  • 12 Mar 2016
  • PHP
Risposte
0
Visite
1K
PHP 12 Mar 2016
jumpy83
J
P
problemi inserimento dati
  • paperinik4
  • 8 Mar 2016
  • PHP
Risposte
1
Visite
1K
PHP 8 Mar 2016
paperinik4
P
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • PHP
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?