dppcyt6157
dppcyt6157
2018-02-18 18:59

我的SQL语法错误让我反复头痛

已采纳

There is a problem signing you up. You have an error in your SQL syntax;

check the manual that corresponds to your MariaDB server version for the right syntax to use near 'way', 'ENGLAND', 'sn66er', 'Home Owner', '6months', '1793321653', '', 'state', '' at line 1

Hello, new to PHP and am struggling with the code as everything I try to run, I get this error. Please, what am I missing? I have checked the other related questions and tried everything without success:

$query = "INSERT INTO users  (Title, username, password, marital_status,
dependents, name, lastname, email, loan_purpose, employment_status,
employer_name, work_address, work_region, work_postcode, work_mobile,
employment_type, time_employer, payment_frequency, wages_paid_into_account, 
othermonthly_income, rent_mortgages, creditcards_loans, 
othermonthly_expenses, account_name, bank_name, account_no, sortcode,
yearswith_bank, heard_about_us, address, region, postcode, residential_type,
time_address, mobile, landline, county, birthdate, income, nextpaydate, Loanamount, Terms, Monthlyrepayment, Totalrepayment, Interest, gender)
VALUES ('$title', '$username',  '$password', '$maritalstatus', '$dependant',
'$name', '$lastname', '$email', '$loanPurpose', '$employmentStatus', 
'$employerName', '$employerAddress', '$employerRegion', '$workpostcode', 
'$workphone', '$employmentType', '$employmentLength', '$paymentFrequency',
'$howYouGetPaid', '$otherIncome', '$rent_mortgage',
'$creditCard_loansExpenses', '$otherMonthlyExpenses', '$accountName',
'$bankName', '$accountNumber', '$sortCode', '$accountLength',
'$hearAboutUs',  $address', '$region', '$postcode', '$tenancyType', 
'$timeatAddress', '$mobilenumber', '$landline', '$county', '$birth',
'$income', '$nextPay', '$loanamount', '$terms', '$monthlyrepayment',
'$totalrepayment', '$interest', '$gender')";


if (mysqli_query($connection, $query)){     
    $_SESSION["username"] =$username; 
    echo " Successfully logged in";
    header("location: login.php");
}
    //create a variable to see if it went through
    // $result =  mysqli_query($connection,  $query ); // assign variable
else{

    die("<p> There is a problem signing you up.</p>" . mysqli_error($connection));

}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • duanchigeng4313 duanchigeng4313 3年前

    missing single quote before $address

    $query = "INSERT INTO users (Title, username, password, marital_status, dependents,
                 name, lastname, email, loan_purpose, employment_status, employer_name, 
                 work_address, work_region, work_postcode, work_mobile, employment_type, 
                 time_employer, payment_frequency, wages_paid_into_account,
                  othermonthly_income, rent_mortgages, creditcards_loans, 
                  othermonthly_expenses, account_name, bank_name, account_no, 
                  sortcode, yearswith_bank, heard_about_us, address, region, 
                  postcode, residential_type, time_address, mobile, landline, 
                  county, birthdate, income, nextpaydate, Loanamount, Terms, 
                  Monthlyrepayment, Totalrepayment, Interest, gender) 
          VALUES ('$title', '$username', '$password', '$maritalstatus', '$dependant', 
              '$name', '$lastname', '$email', '$loanPurpose', '$employmentStatus', 
              '$employerName',  '$employerAddress', '$employerRegion', '$workpostcode', '$workphone', 
              '$employmentType',  '$employmentLength', '$paymentFrequency', '$howYouGetPaid', '$otherIncome', 
              '$rent_mortgage', '$creditCard_loansExpenses', '$otherMonthlyExpenses', '$accountName', 
              '$bankName', '$accountNumber', '$sortCode', '$accountLength', '$hearAboutUs', '$address', 
              '$region', '$postcode', '$tenancyType', '$timeatAddress', '$mobilenumber',
               '$landline', '$county', '$birth', '$income', '$nextPay', '$loanamount', '$terms', 
           '$monthlyrepayment', '$totalrepayment', '$interest', '$gender')";
    
    点赞 评论 复制链接分享
  • duanjiu1950 duanjiu1950 3年前

    You just missed single Quote ' before $address.

    INSERT INTO users              (title,               username,               password,               marital_status,               dependents,               NAME,               lastname,               email,               loan_purpose,               employment_status,               employer_name,               work_address,               work_region,               work_postcode,               work_mobile,               employment_type,               time_employer,               payment_frequency,               wages_paid_into_account,               othermonthly_income,               rent_mortgages,               creditcards_loans,               othermonthly_expenses,               account_name,               bank_name,               account_no,               sortcode,               yearswith_bank,               heard_about_us,               address,               region,               postcode,               residential_type,               time_address,               mobile,               landline,               county,               birthdate,               income,               nextpaydate,               loanamount,               terms,               monthlyrepayment,               totalrepayment,               interest,               gender)  VALUES      ('$title',               '$username',               '$password',               '$maritalstatus',               '$dependant',               '$name',               '$lastname',               '$email',               '$loanPurpose',               '$employmentStatus',               '$employerName',               '$employerAddress',               '$employerRegion',               '$workpostcode',               '$workphone',               '$employmentType',               '$employmentLength',               '$paymentFrequency',               '$howYouGetPaid',               '$otherIncome',               '$rent_mortgage',               '$creditCard_loansExpenses',               '$otherMonthlyExpenses',               '$accountName',               '$bankName',               '$accountNumber',               '$sortCode',               '$accountLength',               '$hearAboutUs',               '$address',               '$region',               '$postcode',               '$tenancyType',               '$timeatAddress',               '$mobilenumber',               '$landline',               '$county',               '$birth',               '$income',               '$nextPay',               '$loanamount',               '$terms',               '$monthlyrepayment',               '$totalrepayment',               '$interest',               '$gender') 

    点赞 评论 复制链接分享

相关推荐