1

Why does this code not work? I need to insert a new record on mysql called "utenti" but this code doesn't work:

<?php
    $nome = $_REQUEST["nomeUtente"];
    $cognome = $_REQUEST["cognome"];
    $psw = $_REQUEST["psw"];
    $email = $_REQUEST["email"];
    $cell = $_REQUEST["num"];           

    echo $nome . " / " . $cognome . " / " . $psw . " / " . $email . " / " . $cell;
    echo "<br>";

    $conn = mysql_connect("hostName","User","password");

    if(!$conn){
        echo "connessione non satabilita";
    }else{
        if(!mysql_select_db("a4102239_utenti",$conn)){
            echo "database non trovato";
        }else{
            $sql = "INSERT INTO utenti (id,psw,nome,cognome,email,cellulare) VALUES (NULL,'$psw','$nome','$cognome','$email','$cell')"; //costruzione comando di ricerca      
        }
    }
?>
1
  • 1
    You must run your query, of course! mysql_query($sql, $conn); Commented Sep 2, 2015 at 11:06

2 Answers 2

1

Execute the query

mysql_query("INSERT INTO utenti (id,psw,nome,cognome,email,cellulare) VALUES (NULL,'$psw','$nome','$cognome','$email','$cell')"); //costruzione comando di ricerca
Sign up to request clarification or add additional context in comments.

Comments

0

Because you did not Execute the Query,

$sql = "INSERT INTO utenti (id,psw,nome,cognome,email,cellulare) VALUES (NULL,'$psw','$nome','$cognome','$email','$cell')";
$result=mysql_query($sql);
if($result){
// Query is executed
}
else{
//Error
echo mysql_error();
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.