Parse error: syntax error, unexpected T_VARIABLE o

2019-02-26 00:40发布

问题:

I am new to PHP and am encountering this parsing error. My code is:

 <?php
   $con=mysqli_connect("glcmcrusaders.ipagemysql.com", "cycregister", "Crusaders13!",          
    "registration")


    $sql="INSERT INTO camperregistration (camperFirstName, camperLastName, camperGender,       
    camperBirthdate, camperStreet, camperCity, camperState, camperZip, camperCountry,   
    camperShirtSize, guardianFirstName, guardianLastName, guardianStreet, guardianCity,  
    guardianState, guardianZip, guardianCountry, guardianCell, guardianEmail,  
    alternateFirstName, alternateLastName, alternateStreet, alternateCity, alternateState, 
    alternateZip, alternateCountry, alternateCell, alternateRelationship, camperSwimming)
    VALUES 
    ('$_POST[camperFirstName]', '$_POST[camperLastName]', '$_POST[camperGender]',     
    '$_POST[camperBirthdate]', '$_POST[camperStreet]', '$_POST[camperCity]',   
    '$_POST[camperState]', '$_POST[camperZip]', '$_POST[camperCountry]',  
    '$_POST[camperShirtSize]', '$_POST[guardianFirstName]', '$_POST[guardianLastName]', 
    '$_POST[guardianStreet]', '$_POST[guardianZip]', '$_POST[guardianCountry]', 
    '$_POST[guardianCell]', '$_POST[guardianEmail]', '$_POST[alternateFirstName]', 
    '$_POST[alternateLastName]', '$_POST[alternateStreet]', '$_POST[alternateCity]',
    '$_POST[alternateState]', '$_POST[alternateZip]', '$_POST[alternateCountry]',  
    '$_POST[alternateCell]', '$_POST[alternateRelationship]', '$_POST[camperSwimming]')";

     mysqli_close($con);
     ?>

Line 5 starts at the %sql ="INSERT INTO... ends at camperSwimming) I am not sure what I am doing wrong.

回答1:

Missing a semi-colon:

$con=mysqli_connect("glcmcrusaders.ipagemysql.com", "cycregister", "Crusaders13!",          
"registration") // <-- HERE


回答2:

you need a terminator(;) at the end of $con.

$con=mysqli_connect("glcmcrusaders.ipagemysql.com", "cycregister", "Crusaders13!",          
    "registration");
                   ^Here