php - Why insert query does not work? -


my code returns success, not insert record table "bekuldottkerdesek". causing problem?

even select command fails, when start echo records table.

this how table looks: imgur

    <?php $servername = "***"; $username = "***"; $password = "***"; $dbname = "***";  $conn = new mysqli($servername, $username, $password, $dbname); date_default_timezone_set('europe/bucharest'); $current_date = date("y-m-d h:i:s"); if ($conn->connect_error) {     die("connection failed: " . $conn->connect_error); }  $check="select * bekuldottkerdesek kerdes = '$_post[kerdes]'"; $res = mysqli_query($conn,$check); if($res->num_rows){    header("location: /bekuld.php?hiba=1"); }   else   {     $var1 = isset($_post['at']) ? 1 : 0;     $var2 = isset($_post['bt']) ? 1 : 0;     $var3 = isset($_post['ct']) ? 1 : 0;     $sql = "insert bekuldottkerdesek (datum, kerdes, a, b, c, at, bt, ct)     values ('$current_date', '$_post[kerdes]', '$_post[a]', '$_post[b]', '$_post[c]', $at, $bt, $ct)";      if ($conn->query($sql) === true) {         echo "new record created successfully";     } else {         echo "error: " . $sql . "<br>" . $conn->error;     }     header("location: /bekuld.php?hiba=2");   } $conn->close(); ?>  

change insert statment ,error passing data $_post

 $sql = "insert bekuldottkerdesek (datum, kerdes, a, b, c, at, bt, ct)     values ('$current_date', '{$_post['kerdes']}', '{$_post['a']}', '{$_post['b']}', '{$_post['c']}', $at, $bt, $ct)"; 

and change statment

$check="select * bekuldottkerdesek kerdes = '$_post[kerdes]'"; 

to

$check="select * bekuldottkerdesek kerdes = '{$_post['kerdes']}'"; 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -