<?PHP
    include("db.php");
    $sql="INSERT INTO registration (`user_name`,'user_email','user_contact_no','user_address','user_dateofbirth','user_gender','user_photo')
    VALUES ('"$_POST['fullname']."','"$_POST['userid']"','"$_POST['cno']"','"$_POST['add']"','"$_POST['dateofbirth']"','"$_POST['gender']"','"echo'<img src= "upload/".$img>'"')";

?>

how to fix this

3 Answers

2
SAVe On

Check this --

<?PHP
    include("db.php");
    $sql="INSERT INTO registration (`user_name`,'user_email','user_contact_no','user_address','user_dateofbirth','user_gender','user_photo')
    VALUES ('".$_POST['fullname']."','".$_POST['userid']."','".$_POST['cno']."','".$_POST['add']."','".$_POST['dateofbirth']."','".$_POST['gender']."','<img src= /upload/'".$img.">')";
?>
1
Community On

join variables with periods. escape double quotes used when inserting the img tag.

although you might just want to save the path to the photo instead.

$sql="INSERT INTO registration (`user_name`,'user_email','user_contact_no','user_address','user_dateofbirth','user_gender','user_photo')
    VALUES ('".$_POST['fullname']."','".$_POST['userid']."','".$_POST['cno']."','".$_POST['add']."','".$_POST['dateofbirth']."','".$_POST['gender']."','<img src=\"upload/".$img."\"')";

without using image tag

$sql="INSERT INTO registration (`user_name`,'user_email','user_contact_no','user_address','user_dateofbirth','user_gender','user_photo')
    VALUES ('".$_POST['fullname']."','".$_POST['userid']."','".$_POST['cno']."','".$_POST['add']."','".$_POST['dateofbirth']."','".$_POST['gender']."','upload/".$img."')";
1
Community On

Try This --

<?PHP
    include("db.php");

    $fullname = $_POST['fullname'];
    $userid = $_POST['userid'];
    $cno = $_POST['cno'];
    $add = $_POST['add'];
    $dateofbirth = $_POST['dateofbirth'];
    $gender = $_POST['gender'];

    $sql="INSERT INTO registration (`user_name`,'user_email','user_contact_no','user_address','user_dateofbirth','user_gender','user_photo')
    VALUES ('".$fullname"','".$userid."','".$cno."','".$add."','".$dateofbirth."','".$gender."','<img src= /upload/'".$img.">')";
?>