Hi Guys,
I'm trying to use the following PHP code to query some entries in a MySQL database but I just can't get it to work:
PHP Code:
<?php
$link = mysql_connect("[My Database]", "dbmapserver", "[Password]")
or die("Could not connect: " . mysql_error());
mysql_selectdb("dbmapserver",$link) or die ("Can\'t use dbmapserver : " . mysql_error());
$result = mysql_query("SELECT * FROM 'memberlocations'",$link);
if (!$result)
{
echo "no results ";
}
while($row = mysql_fetch_array($result))
{
echo "var point = new GPoint(" . $row['lon'] . "," . $row['lat'] . ");\n";
echo "var marker = createMarker(point, '" . $row['desc'] . "');\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}
mysql_close($link);
?>
Where it says "[My Database]" I need to put in the name of my database (Duh!), the database is hosted on my I-Web hosting account as a MySQL database and is called "catswor_maps" - what should I put in as the name of the database? Do I need to include the full path of the site? Do I just put in the database name?
I know what the password is (I just blanked it out above) so that's not an issue. Do I need to include a user name somewhere though?
Any thoughts would be greatly appreciated.
When I upload the page containing this code to my site it simply displays a blank page, if I take this section of code out everything is ok and I get the results I'm expecting.
Here's the page
without the PHP included.
http://www.catsworthpcs.co.uk/maps/example.htm