I'm trying to connect a MySQL server to my phonegap application. I currently have a localhost MySQL and Apache Server running on XAMPP. Here is my PHP script that I am using to call a simple SELECT statement on my server:
$(function() {
window.Parsley.on('field:validate', function() {
var form = this.$element.closest("form"),
submit = form.find('.xbtn-submit');
if (form.parsley().isValid()) {
submit.removeAttr("disabled");
} else {
submit.attr("disabled", "disabled");
}
});
});
Next, I make an jQuery JSON call within my javascript in order to obtain the information and simply print it out on my page.
<?php
$host="localhost";
$port=3306;
$socket="";
$user="root";
$password="";
$dbname="mydb";
$con = new mysqli($host, $user, $password, $dbname, $port, $socket)
or die ('Could not connect to the database server' . mysqli_connect_error());
$sql = "SELECT * FROM users";
$result = $conn->query($sql);
$array = $result->fetch_row($result);
echo json_encode($array);
mysqli_close($con);
?>
Yet whenever I attempt to run this code, the ajax call errors out and my browser returns a Status:200 and statusText:OK.
I would really appreciate any help on this matter. Thanks!
答案 0 :(得分:0)
感谢@jcesarmobile,我能够找出问题所在。您不能将.php脚本存储在项目的目录中。