-4

I am getting the Parse error: syntax error, unexpected end of file regardless of what I change/add to my code, the error constantly tells me that there is something wrong with my last line.

My PHP file should be saving form input to the database but this error seems to be getting in the way and I cannot figure out what is causing it.

PHP Code

<?php

function so56917978_upload_callback() {  

    //Register variables

    $adddate = $_POST['adddate'];
    $addcontact = $_POST['addcontact'];
    $adda = $_POST['adda'];
    $addb = $_POST['addb'];
    $addincome = $_POST['addincome'];
    $addpayment = $_POST['adddate'];
    $addsubbie = $_POST['addsubbie'];
    $addcust = $POST['addcust'];

    //connect with Database

    $host_name = 'zzz.hosting-data.io';
    $database = 'zzz';
    $user_name = 'zysql_connect($host_name, $user_name, $password);

    if(!$connect) {
        die('Not Connected To Server');
    }

    //Connection to database
    if(!mysql_select_db($connect, $database)) {
        echo 'Database Not Selected';
    }
    $query = mysql_query($connect,"SELECT * FROM table WHERE adddate = '$adddate' OR addcontact = '$addcontact' OR adda= '$adda' OR addb = '$addb' OR addincome = '$addincome' OR addpayment = '$addpayment' OR addsubbie = '$addsubbie' OR addcust = '$addcust'");
    $sql = "INSERT INTO table (adddate, addcontact, adda, addb, addincome, addpayment, addsubbie, addcust) VALUES ('$adddate', '$addcontact', '$adda', '$addb', '$addincome', '$addpayment', '$addsubbie', '$addcust')";

    if (!mysql_query($connect,$sql)) {
        die('Error: ' . mysql_error($connect));
    }
    echo "1 record added";

    mysql_close($connect);
2
  • Your function doesn't end with }, so PHP will unexpectedly hit the end of the file. That is EXACTLY what the error means. Further, there is a single quote that isn't closed. Commented Sep 4, 2019 at 19:19
  • 2
    The syntax highlighting on this page should help identify the issue... $user_name =... Commented Sep 4, 2019 at 19:20

1 Answer 1

0
<?php

function so56917978_upload_callback() {  

    //Register variables

    $adddate = $_POST['adddate'];
    $addcontact = $_POST['addcontact'];
    $adda = $_POST['adda'];
    $addb = $_POST['addb'];
    $addincome = $_POST['addincome'];
    $addpayment = $_POST['adddate'];
    $addsubbie = $_POST['addsubbie'];
    $addcust = $POST['addcust'];

    //connect with Database

    $host_name = 'zzz.hosting-data.io';
    $database = 'zzz';
    $user_name = 'zysql_connect($host_name, $user_name, $password);

    if(!$connect) {
        die('Not Connected To Server');
    }

    //Connection to database
    if(!mysql_select_db($connect, $database)) {
        echo 'Database Not Selected';
    }
    $query = mysql_query($connect,"SELECT * FROM table WHERE adddate = '$adddate' OR addcontact = '$addcontact' OR adda= '$adda' OR addb = '$addb' OR addincome = '$addincome' OR addpayment = '$addpayment' OR addsubbie = '$addsubbie' OR addcust = '$addcust'");
    $sql = "INSERT INTO table (adddate, addcontact, adda, addb, addincome, addpayment, addsubbie, addcust) VALUES ('$adddate', '$addcontact', '$adda', '$addb', '$addincome', '$addpayment', '$addsubbie', '$addcust')";

    if (!mysql_query($connect,$sql)) {
        die('Error: ' . mysql_error($connect));
    }
    echo "1 record added";

    mysql_close($connect);
}

You forgot the closing }

Sign up to request clarification or add additional context in comments.

3 Comments

And at least one single quote as the comment re. syntax highlighting states.
No way lol. Now I feel daft. Thank you, Something so simple as well!!
I'm curious what editor you are using, a basic code editor would have warned you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.