i am makin a simple account creation screen for my website and i have an error: Error: No database selected and i dont know why im getting this because i have used mysql_select_db(), heres my code:
<?php
$con = mysql_connect("localhost");
if (!$con)
{
echo "Could not connect:" . mysql_error() . "<br />";
echo "If you are a visitor, please contact the site author <br />or one of the administrators.";
}
mysql_select_db("anzak_site", $con);
$sql = "INSERT INTO user_accounts (first_name, last_name, age, username, password)" .
"VALUES" .
"(\"$_REQUEST[firstname]\",\"$_REQUEST[lastname]\",\"$_REQUEST[age]\",\"$_REQUEST[username]\",\"$_REQUEST[password]\")";
if (!mysql_query($sql, $con))
{
echo "Error: " . mysql_error();
}
else
{
echo "One(1) record added.";
}
mysql_close($con);
?>
any help would be appreciated :)