zioarnold Posted June 6, 2016 Share Posted June 6, 2016 Greetings collegues, having these codes below: This reading the data from MySQL DB and fill it on select (don't screw the teachers are pretending to use this method)The next one is the query. The problem is if I try to select for example 2016. In my phpMyAdmin database I retrieve the value 2032. So to select some data I need to make some difference about 16 - and it works. THe problem is the registration. When I try to insert a new user (student whatever it is) and if I select 1985 on my DB results 0000, meanwhile the insert something anno_maturita = $casellaAnnoScolastico - 16 (it works). <select name="casellaAnnoScolastico" title="Anno Maturità"> <?php include "../connect/connetti.php"; $conn = new mysqli("localhost", "root", "", "archivio_studenti"); echo '<option value="none">Nessuno</option>'; $query = "SELECT ID, anno FROM annoscolastico ORDER BY ID ASC "; $result = mysqli_query($conn, $query); while ($row = $result->fetch_assoc()) { unset($id, $name); $id = $row['ID']; $anno = $row['anno']; echo '<option value="' . $id . '">' . $anno . '</option>'; } ?> </select> $query = "INSERT INTO utenti_studenti (nome, cognome, password ,via_piazza,n_civico,cap, localita, anno_maturita, voto_maturita, email, telefono , confermato, cod_azienda) VALUES ('$nome','$cognome','$password','$via_piazza','$n_civico','$codice_cap', '$comune','$casellaAnnoScolastico'-16,'$votoMaturita','$email','$telefono', 1, '$casellaAzienda')"; $risultato = mysqli_query(new mysqli("localhost", "root", "", "archivio_studenti"), $query); INSERT INTO utenti_studenti (nome, cognome, password, via_piazza, n_civico, cap, localita, anno_maturita, voto_maturita, email, telefono, confermato, cod_indirizzo_studio, cod_azienda, cod_facolta) VALUES('phpstorm', 'jetbrains', 123123123, 'via', '15', 151515, 'Munchen', '2016'-16, 100, 'email@email.it', 393462133945, 0, NULL, NULL, NULL); Link to comment Share on other sites More sharing options...
justsomeguy Posted June 6, 2016 Share Posted June 6, 2016 In both cases you're subtracting a number from a string, because you have quotes around it. What is the data type of that field in the database? Link to comment Share on other sites More sharing options...
zioarnold Posted June 7, 2016 Author Share Posted June 7, 2016 Solve it...Ok Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now