当试图从iOS应用程序访问它时,PHP脚本已经崩溃


PHP script has been crashing when trying to access it from iOS app

我是ios编程的新手,我正试图将ios应用程序连接到mysql服务器,我得到的错误如下,我已经发布了请帮助我关于这一点。下面是我的PHP脚本

<?php
            $host = ’localhost’;
            $user = ‘’;
            $password = ‘’;

            $connection = mysqli_connect($host,$user,$password);

            $fname = $_POST[‘a’];
            $lname = $_POST[‘b’];
            $school = $_POST[‘c’];
            if(!$connection){
                            die(‘connection failed’);
            }
            else{
                    $dbconnect = @mysqli_select_db(‘pnallama’,$connection);
                    if(!$dbconnect){
                                    die(‘connection to DB failed’);
                    }
                    else{
                            $query = “INSERT INTO ‘pnallama’.’DataCollector’ (‘firstname’, ‘lastname’, ‘school’) VALUES (‘$fname’, ‘$lname’, ‘$school’);”;
                            mysqli_query($query, $connection) or die(mysqli_error());
                            echo ‘successfully added’;
                            echo $query;
                    }
            }
?>
我的视图控制器是
import UIKit

类CollectorDetailView: UIViewController, UITextFieldDelegate {

@IBOutlet weak var textField1: UITextField! = nil
@IBOutlet weak var textField2: UITextField! = nil
@IBOutlet weak var textField3: UITextField! = nil
@IBAction func submitBtnPressed(_ sender: UIButton) {
    let request = NSMutableURLRequest(url: NSURL(string: "http://kindlewell.com/~pnallama/insert.php")! as URL)
    request.httpMethod = "POST"
    let postString = "a='(textField1.text!)&b='(textField2.text!)&c='(textField3.text!)"
    request.httpBody = postString.data(using: String.Encoding.utf8)
    let task = URLSession.shared.dataTask(with: request as URLRequest) {data, response, error in
        if error != nil {
            print("error='(error)")
            return
        }
        print("response='(response)")
        let responseString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
        print("responseString ='(responseString)")
        }
    task.resume()
    }
override func viewDidLoad() {
    super.viewDidLoad()
    textField1.delegate = self
    textField2.delegate = self
    textField3.delegate = self
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool // called when 'return' key pressed. return NO to ignore.
{
    textField.resignFirstResponder()
    return true;
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}
}

,我得到一个错误,像这样

response=Optional(<NSHTTPURLResponse: 0x60800022ad60> { URL: http://kindlewell.com/~pnallama/insert.php } { status code: 500, headers {
Connection = close;
"Content-Length" = 0;
"Content-Type" = "text/html";
Date = "Wed, 12 Oct 2016 06:31:26 GMT";
Server = "Apache/2.4.6 (Linux/SUSE)";
"X-Powered-By" = "PHP/5.4.20, Mono";
} })
(lldb) 

尝试用单引号代替双引号,并尝试在不带引号的查询中命名表我曾经遇到过同样的问题,然后发现它正在到来,因为我把表名放在引号里试着去做,如果有帮助的话告诉我