mysqli - PHP CRUD Unknown column in 'where clause' -


i creating crud page. i've been able insert data database, following code:

    $query="insert user(user_id, password, first_name, last_name, contact_no, shipping_address, billing_address, email) values('$user_id', '$password', '$first_name', '$last_name', '$contact_no', '$shipping_address', '$billing_address', '$email')"; if(mysqli_query($con, $query)) { echo "<center><font color=#ff0000>record inserted!</font></center><br>"; } else{printf("error: %s\n", mysqli_error($con));}     } } 

however, unable delete nor edit data "unknown column in 'where clause' " error appear. i've tried finding solutions on google did not work. can see if there errors in code?

the following codes editting data in database:

$query="update user set user_id='$user_id' , password='$password', first_name='$first_name', last_name='$last_name', contact_no='$contact_no', shipping_address='$shipping_address', billing_address='$billing_address', email='$email' user_id=".$_post['user_id']; if(mysqli_query($con, $query)) {     echo "<center><font color=#ff0000>record updated!</font></center><br>"; } else{printf("error: %s\n", mysqli_error($con));} } 

the following codes deleting data in database:

    if(isset($_get['operation'])){     if($_get['operation']=="delete")     {         $query="delete user user_id=".$_get['user_id'];           if(mysqli_query($con, $query))         {             echo "<center><font color=#ff0000>record deleted!</font></center><br>";         }         else{printf("error: %s\n", mysqli_error($con));}     } } 

i guess user_id coulmn type varchar, query string throws result update ... user_id=id1; mysql assumes id1 column , throws unknown column. better use quote in code update ... user_id='".$_post['user_id']."'


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -