Hi,
Im getting the error
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'map1user'@'localhost' (using password: YES) in C:\xampp\htdocs\projectgmaps\config.php on line 7
and
Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\projectgmaps\config.php on line 7
Not connected : Ah sh*t
config.php file:
<?php
$host = "localhost";
$user = "map1user";
$password = "map1password";
$database = "map1";
$connection = mysqli_connect ($host, $user, $password) or die('Not connected : Ah sh*t ' . mysqli_error());
?>
Otherfile:
<?php
require("config.php");
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// Opens a connection to a MySQL server
//$connection=mysqli_connect ('localhost', 'username', 'password');
//if (!$connection) {
// die('Not connected : Ah sh*t ' . mysqli_error());
//}
// Set the active MySQL database
$db_selected = mysqli_select_db($database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysqli_error());
}
$query = "SELECT * FROM markers WHERE 1";
$result = mysqli_query($query);
if (!$result) {
die('Invalid query: ' . mysqli_error());
}
header("Content-type: text/xml");
echo "<?xml version='1.0' ?>";
echo '<markers>';
$ind=0;
while ($row = @mysqli_fetch_assoc($result)){
echo '<marker ';
echo 'id="' . $row['id'] . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
$ind = $ind + 1;
}
echo '</markers>';
?>
I'm actually following the guide by google on https://developers.google.com/maps/documentation/javascript/mysql-to-maps#echoxml
But its giving me those errors. Does anyone know why? (Im on the Checking the XML output bit using the echo option)
What I have tried:
Ive tried typing the usernames and passwords in directly and via variable.
Ive tried moving the mysqli connect function to the config file instead
Ive tried creating a new database, a new user, a new table.
I cant get this working.
Any help appreciated!