Mashhood Ali
Mashhood Ali

Reputation: 127

Update query is not working correctly

I am making a code for editing a text area. The query runs correctly without any errors but the textarea is not updated. Can anyone help me with it please?

<html>
    <body bgcolor="skyblue">
    <form method= "post" enctype="multipart/form-data" action="upd.php">
        <table align="center" width="795" border="2" bgcolor="#CCC">
            <?php
                $i=0;
                $sel="select * from video";
                $sel_query=mysqli_query($con, $sel);
                while($row=mysqli_fetch_array($sel_query)){
                    $i++;
                    $var_id=$row['v_id'];
                    $var=$row['video'];
                    ?>
                    <tr align="center">  
                        <td  align="right">
                            <br>
                            <h2>Upadte Video <?php echo $i; ?> Link: </h2>
                            <button type="submit" name="btn">
                                <a name="upd" href="upd.php?insert_brand=<?php echo $var_id; ?>&fram=<?php echo $var; ?>">Update</a>
                            </button>
                            <td align="left"><br><textarea name="vids" rows="4" cols="50"><?php echo $var; ?>"</textarea></td>
                        </td>
                    </tr>
                    <?php
            }
            ?> 
        </table>
    </form>

upd.php

<?php
    include ("includes/db.php");
    $check=@$_GET['insert_brand'];
    if(isset($_POST['btn'])){
        $vids=$_POST['vids'];
        $upds="UPDATE `video` SET `video`='$vids' WHERE `v_id`='$check'";
        $query=mysqli_query($con, $upds);
        if($query){
            echo 'The query is executed';
        }
        else{
            echo 'There was an error'. mysqli_error($con);
        }
    }
?>

Upvotes: 0

Views: 43

Answers (1)

ManiMuthuPandi
ManiMuthuPandi

Reputation: 1604

Have you tried mysql_real_escape_string() to retrieve textarea data.

Upvotes: 1

Related Questions