Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

NEED HELP STORING FORM DATA ONTO MYSQL DATABASE

General discussions related to php

Moderators: macek, egami, gesf

NEED HELP STORING FORM DATA ONTO MYSQL DATABASE

Postby ammaflagathon » Mon Jan 14, 2013 12:36 pm

:help:
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!
I'm running out of time! :(
ammaflagathon
New php-forum User
New php-forum User
 
Posts: 4
Joined: Sat Jan 12, 2013 12:23 am

Return to PHP General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.