php - my data are not showing in phpmyadmin db -


kindly check code.. data not show in db field. send db file. when enter data not show in db.i try lots of time.this newsletter subscriber code

    <?php  $name = ""; $email = ""; $msg_to_user = "";  if (isset($_post['name'])) {      include "connect_to_mysql.php";      // sure filter data deter sql injection, filter before querying database     $name = $_post['name'];     $email = $_post['email'];     <!--check queryy -->     $result = "select * newsletter email='$email' ";      $num_rows = @mysqli_num_rows($result);     @mysqli_query($num_rows);       if (!$email) {          $msg_to_user = '<br /><br /><h4><font color="ff0000">please type email address ' . $name . '.</font></h4>';      } else if ($num_rows > 0) {          $msg_to_user = '<br /><br /><h4><font color="ff0000">' . $email . ' in system.</font></h4>';      } else {           $sql_insert = "insert newsletter (name, email, datetime)                                                      values('$name','$email',now() )"  or die (mysqli_error($con));          $msg_to_user = '<br /><br /><h4><font color="0066ff">thanks ' . $name . ', have been added successfully.</font></h4>';         $name = "";         $email = "";     } }  ?> 

you have multiple issues:

  1. you have execute query before check number of rows returned
  2. you never execute query because don't pass right variable mysqli_query()
  3. you don't capture result of query pass mysqli_num_rows()
  4. you're missing connection parameter mysqli function clls

fixes:

$sql      = "select * newsletter email='$email' "; $result   = mysqli_query($conn, $sql); $num_rows = mysqli_num_rows($result); 

you should turn on error reporting tell these kind of things. also, stop using @ operator hides errors , bad programming smell.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -