SYNTAX error: unexpected 'fname' (T_STRING)

Ask about general coding issues or problems here.

Moderators: gesf, Michalio

Post Reply
Rocky1948
New php-forum User
New php-forum User
Posts: 7
Joined: Tue Aug 16, 2022 12:00 pm

I am trying to write some code to extract some information from a form using PDO.
the line that gives the error is:

Code: Select all

 $parms = array(
            'fname'=>$fname,
            'sname'=>$sname,
            'email'=>$email,
            'addr'=>$addr,
            'phone'=>$phone,
            'mob'=>$mob,
            'bmfa_no'=>$bmfa_no,
            'caa_no'=>$caa_no,
            'rewd'=>$rewd,
            'fam'=>$fam,
            'ctry'=>$ctry,
            'ctry_bmfa'=>$ctry_bmfa,
            'bdf'=>$bdf,
            'payopt'=>$payopt,
            'pay'=>$pay,
            'date'=>$date,
            'sign'>$sign
            );
            
The error is on the first item of the array, but I guess each element would give the same result.
This part of the code sets up an array which is then executed with the following line:
if (!$stmt->execute($parms))
I was getting errors on the previous 2 lines, but I seem to have cleared that.
Here are the previous lines:

Code: Select all

 $sql = 'INSERT INTO senior_dat(fname,sname,email,dob,addr,phone,mob,bmfa_no,caa_no,rewd,fam,ctry,ctry_bmfa,bdf,payopt,pay,date,sign)
                VALUES (:fname, :sname, :email,:dob, :addr, :phone, :mob, :bmfa_no, :caa_no, :rewd, :fam, :ctry, :ctry_bmfa, :bdf, :payopt, :pay, :date, :sign);
        $stmt = $conn->prepare($sql);
        
I can send you the complete file if you think that will help!
User avatar
Michalio
Moderator
Moderator
Posts: 317
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

Is the error pointed exactly to the line with the array?
The code looks fine, so maybe there is another place where the fname is placed in wrong way
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
Post Reply