php - Cannot Insert details to my site with INERT Query (using MySqli) -


i'm trying install php code inside html file present club friends using select query mysql. can't see results inside page. need help. here's entire php code integrated inside html:

   <?php //input posted data. $fname = $_post["fname"]; $lname = $_post["lname"]; $mail = $_post["mail"]; $row = $_post["row"];    // create connection $conn = mysqli_connect('localhost','root',"");   //check if connection opened, if not prompt error page. if (!$conn) {   die('could not connect: ' . mysqli_error()); }  //select data base. mysqli_select_db($conn, "club");  //set character set utf-8 allow hebrew. mysqli_query($conn, "set names 'utf8'");      //sql query - user details  $sql = "select fname, lname, mail customers";  //run sql query $results = mysqli_query($conn, $sql) or die (mysqli_connect_errno());  if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) {     echo "fname: " . $row["fname"]. " - name: " . $row["lname"]. " " . $row ["mail"]. "<br>"; } } else { echo "0 results"; }       //close sql connection. mysqli_close($conn);   ?>  

thanks in advance, jasonb.

remove "s" $result variable. line:

$results = mysqli_query($conn,... 

have become:

$result = mysqli_query($conn,... 

in code assign $_post data few unused variables. used typically when want filter data database. when want add "where" clause example. , if want use $_post data, should sanitize it.

you can add right after opening php tag:

error_reporting(-1); ini_set('display_errors', 1); 

add in development environment or see if there errors , remove after errors fixed.


Comments