php mysql new mysqli localhost root ajaxTut or die There was problem i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<?php
$mysql = new mysqli("localhost", "root", "", "ajaxTut") or die("There was a problem");
if($result = $mysql->query("SELECT * FROM contactInfo")) {
$dataArray = array();
while($row = $result->fetch_object()) {
$dataArray[] = $row;
}
echo json_encode($dataArray);
} else {
trigger_error("Error: " . $mysql->error);
}