I am trying to save the information stored in the SQL but this error keeps coming out: "Error Saving Data. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'company = 'GlobalTop Inc.' where regid = 1' at line 6" What seems to be the error?
Here is the full code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<?php
include "db.php";
$gresult = ''; //declare global variable
//Start of edit contact read
if(isset($_POST["action"]) and $_POST["action"]=="edit"){
            $id = (isset($_POST["ci"])? $_POST["ci"] : '');
            $sql = "select regid, regname,
                            address, phone,
                            email,company from tblregistrants
                            where regid = $id";
            $result = mysqli_query($link, $sql);
            if(!$result)
            {
                echo mysqli_error($link);
                exit();
            }
            $gresult = mysqli_fetch_array($result);
            include 'update.php';
            exit();
}
//Insert or Update contact information
if(isset($_POST['action_type']))
{
        if ($_POST['action_type'] == 'add' or $_POST['action_type'] == 'edit')
        {
                //Sanitize the data and assign to variables
                $regid = mysqli_real_escape_string($link, strip_tags($_POST['regid']));
                $regname = mysqli_real_escape_string($link, strip_tags($_POST['regname']));
                $phone = mysqli_real_escape_string($link, strip_tags($_POST['phone']));
                $address = mysqli_real_escape_string($link, strip_tags($_POST['address']));         
                $email = mysqli_real_escape_string($link, strip_tags($_POST['email']));
                $company = mysqli_real_escape_string($link, strip_tags($_POST['company']));
                if ($_POST['action_type'] == 'add')
                {
                    $sql = "insert into tblregistrants set
                                        name = '$regname',
                                        phone = '$phone',
                                        address = '$address',
                                        email = '$email'
                                        company = '$company'";
                }else{
                    $sql = "update tblregistrants set
                                        name = '$regname',
                                        phone = '$phone',
                                        address = '$address',
                                        email = '$email'
                                        company = '$company'
                                        where regid = $regid";
}
        if (!mysqli_query($link, $sql))
        {
            echo 'Error Saving Data. ' . mysqli_error($link);
            exit();
        }
    }
    header('Location: view.php');
    exit();
}
//Read registrants information from database : Stage 1
$sql = "select * from tblregistrants";
$result = mysqli_query($link, $sql);
if(!$result)
{
    echo mysqli_error($link);
    exit();
}
//Loop through each row on array and store the data to $reg_list[] : Stage 2
while($rows = mysqli_fetch_array($result))
{
    $reg_list[] = array('regid' => $rows['regid'],
    'regname' => $rows['regname'],
    'address' => $rows['address'],
    'phone' => $rows['phone'],
    'email' => $rows['email'],
    'company' => $rows['company']);
}
include 'view.php';
exit();
?>
 
     
     
     
    