Guys I'm student trying to create a website using PHP & MySQL.
I'm having hard time accessing the database.
My website has been hosted for testing!
website: [url]ammatest.bugs.com[/url]
In the http://ammatest.bugs3.com/Register.html page when i enter all details & click submit, it will post the values to insert.php, but I'm getting this error!
Error: No database selected
The code of insert.php is:
- Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?php
$con = mysql_connect("mysql.serversfree.com","u967246295_root","anandrao");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test", $con);
$sql="INSERT INTO `reg` (t3, t4, t1, t6, t8, t9, t10, t11, t12) VALUES('$_POST[t3]','$_POST[t4]','$_POST[t1]','$_POST[t6]','$_POST[t8]','$_POST[t9]','$_POST[t10]','$_POST[t11]','$_POST[t12]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "YOU ARE REGISTERED SUCCESSFULLY!";
mysql_close($con);
?>
<body>
</body>
</html>
Please help!
And I've two records in the database already, but when i try to access it, i'm getting numerous errors!
From the Homepage, when i enter the username='abhi' & password='abhi' and click submit, it will redirect to admin.php.
The connection to the database is successfull, but the query below is not returning anything,
- Code: Select all
<?php
$con = mysql_connect("mysql.serversfree.com","u967246295_root","anandrao");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test",$con);
$sql = "SELECT * FROM reg";
$result = mysql_query($sql);
echo "THIS IS: $result !";
if (!$result) {
echo 'Could not run query: ';
}
?>
It shows such output:
THIS IS: !Could not run query:
help neede immediately! I'm running out of time!

