Parsing Error: Syntax Error, Unexpected T_STRING on Line 6

advertisements

I keep getting a

Parse error: syntax error, unexpected T_STRING in /newref-exec.php on line 6

I have read loads of different solutions to this problem but non seem to work

<?php
// connect to database
 require($DOCUMENT_ROOT . "connect.php");
// check for blank entries
if ($_POST[doi2] == "NULL"){
    echo "No Data to add";
    }
    else
    {
    $sql="INSERT INTO ref (uid, date, doi, title, year, journal)
    VALUES
    ('1','CURDATE ()','$_POST[doi2]','$_POST[title2]','$_POST[year2]','$_POST[journal2]')";
    if (!mysqli_query($link,$sql,$con))
        {
        die('The Reference could not be added, beacuse of SQL Error:' . mysql_error());
        }
        echo "New Reference Added";
    }
?>


This line, the key needs to have quotes,

if ($_POST['doi2'] == "NULL"){

Also, if you want to check for empty entries, you need to probably do this,

if ($_POST['doi2'] == ""){ //checking "NULL", checks for a string 'NULL'