php - I'm unable to update the entered data into db -


this question exact duplicate of:

here code

  <?php   include('admin/class.php'); 

this db connection

  $link = mysqli_connect("localhost", "root", "", "timesheet1234"); 

here giving action save button

if(isset($_post['save'])) {     $sel=@$_post['selpro'];   $mon=@$_post['mon'];   $tue=@$_post['tue'];   $wed=@$_post['wed'];   $thu=@$_post['thu'];   $fri=@$_post['fri'];   $sat=@$_post['sat'];   $sun=@$_post['sun']; 

this problem occurs

if(isset($_session['user'])) {     echo "session user"; 

it not accepting mysqli

$stmt = mysqli_prepare($link,"update empdaytimesheet set  `projectcode`='$sel',`mon`='$mon',`tue`='$tue',`wed`='$wed', `thu`='$thu',`fri`='$fri',`sat`='$sat',`sun`='$sun' `username`='".$_session['user']."'"); mysqli_stmt_bind_param($stmt,"siiiiiii", $sel,$mon,$tue,$wed,$thu,$fri,$sat,$sun);  $res= mysqli_stmt_execute($stmt); 

it not coming condition

if($res){   echo "<script type='text/javascript'>";   echo "alert('timesheet saved..!')";   echo "</script>";   echo "<script type='text/javascript'>";   echo "window.location='my_timesheet.php'";   echo "</script>"; } 

instead executes this:

else {   echo "<script type='text/javascript'>";   echo "alert('some error occured ! retry..!')";   echo "</script>";   echo "<script type='text/javascript'>";   echo "window.location='my_timesheet.php'";   echo "</script>"; } }   }   ?> 

your way of using prepared statements wrong.

you have use placeholders instead of variables:

also not checking errors , you're unable ho hint database

$sql  = "update empdaytimesheet set `projectcode`=?',`mon`=? ..."; // , on $stmt = mysqli_prepare($link, $sql) or trigger_error(mysqli_error($link)); 

note second line. raise php error tell what's going wrong


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -