使用PHP向DB添加多个字段

I am currently using the following function:

    if(isset($_REQUEST["function"]) && ($_REQUEST["function"] == "setnm")){
$value = $_REQUEST["value"]; //field to edit

$con=mysqli_connect("localhost", "root", "", "hike_buddy");
//Check Connection

if(mysqli_connect_errno())
{
    echo "failed to connect:".mysqli_connect_error();
}

mysqli_query($con, "INSERT INTO user_com (name) VALUES ('$value')");
mysqli_close($con);

}

How can I alter this code so it will change the value of two fields?

For instance I have a comment and a name column and I want to update them both (different values) with one function.

Never use un-escaped strings specified by the user in your database queries.

So, if you're using mysqli:

$value1 = $con->real_escape_string($_REQUEST['value_1']);
$value2 = $con->real_escape_string($_REQUEST['value_2']);
$query = "INSERT INTO my_table (column_1, column_2) VALUES ('$value1', '$value2')";
$con->query($query);

You can do the following:

if(isset($_REQUEST["function"]) && ($_REQUEST["function"] == "setnm")){
    $value = $_REQUEST["value"]; //field to edit
    $comment = $_REQUEST["comment"]; //This is your comment

    $con=mysqli_connect("localhost", "root", "", "hike_buddy");
    //Check Connection

    if(mysqli_connect_errno())
    {
        echo "failed to connect:".mysqli_connect_error();
    }

    //Edit the query like so to update insert the comment along with the name.
    mysqli_query($con, "INSERT INTO user_com (name, comment) VALUES ('$value', '$comment')");
    mysqli_close($con);
}

Are you trying to INSERT new data in the database or UPDATE existing data?

If you want to update data, you should use the UPDATE statement:

$query = "UPDATE my_table SET column_1 = '$value1', column_2 = '$value2' WHERE my_table_key = '$key'";

Also, you need to escape these variables like har-wradim suggested.