I'm trying to build an sql/php database that can be used offline, but i'm having a bit of trouble getting it working. I downloaded WAMP, which has sql, php, and apache all in one, and sets them all up to work together(apparently). However when i try to run php scripts offline, i can't get them to work. Here's a sample code from the project, used after a user inputs values in fields in a HTML page. The database name is "bands", and i've created a user "david", with password "pass".
<?
$db_name = "band";
$connection =
@mysql_connect("localhost", "david", "pass")
or die(mysql_error());
$db =
@mysql_select_db($db_name, $connection) or die(mysql_error());
{
$sql = "INSERT INTO bookings Values ('$artistname','$venuename','$booked','$fee','$date','$notes')";
if (!mysql_query($sql))
{
echo("<P>Error adding your information " . mysql_error() . "</P>");
exit;
}
}
header("c:\program files\wamp\www\bands\Index.htm");
?>
Because i've never used php offline before, there's a couple of things i'm not sure of. Is my connection statement correct? Do i even need a connection statement? Is there anything else wrong with my code? Do i have to set something else up before i can use the php? Would i be better off scrapping wamp, and just downloading the components individually?