tarleton Posted July 31, 2009 Share Posted July 31, 2009 Hi guys, just playing around with some PHP and MYSQL as of current I have a html form which sends info to a file called formindb.php. Which then posts it into a mysql database, however I keep getting: Parse error: parse error in C:\xampp\htdocs\MODULE\formindb.php on line 14 Any help appreciated below is a copy of the formindb.php script: <?php $con = mysql_connect("(module).localhost","matchreport","matchreport"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("module", $con); $your_team=mysql_real_escape_string($_POST['your_team']); $opp_team=mysql_real_escape_string($_POST['opp_team']); $date=mysql_real_escape_string($_POST['date']); $time=mysql_real_escape_string($_POST['time']); $g_name=mysql_real_escape_string($_POST['opp_team']); $sql="INSERT INTO form_data (your_team, opp_team, date, time, g_name) VALUES ('$your_team','$opp_team', '$date', '$time', '$g_name')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Match Report has been added!."; mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
Adam Posted July 31, 2009 Share Posted July 31, 2009 Is that the entire error? Quote Link to comment Share on other sites More sharing options...
tarleton Posted July 31, 2009 Author Share Posted July 31, 2009 Sure is. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted July 31, 2009 Share Posted July 31, 2009 try changing this: mysql_query($sql,$con) to this: mysql_query($sql) Quote Link to comment Share on other sites More sharing options...
tarleton Posted July 31, 2009 Author Share Posted July 31, 2009 Hi guys managed to fix that problem seems I fail to copy files from dir to my server dir . However as per usual I hit another one straight away. HAS TO BEE SOMTHING SO SIMPLE No Database Selected heres the code again. I appreciate any help cheers. <?php $con = mysql_connect("localhost","root",""); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } // Create a MySQL table in the selected database mysql_query("CREATE TABLE form_data( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), your_team VARCHAR(30), opp_team_team VARCHAR(30), date VARCHAR(20), time VARCHAR(30), g_name VARCHAR(15)") or die(mysql_error()); mysql_select_db("module"); //Replace with your MySQL DB Name $your_team=mysql_real_escape_string($_POST['your_team']); //This value has to be the same as in the HTML form file $opp_team=mysql_real_escape_string($_POST['opp_team']); //This value has to be the same as in the HTML form file $date=mysql_real_escape_string($_POST['date']); //This value has to be the same as in the HTML form file $time=mysql_real_escape_string($_POST['time']); //This value has to be the same as in the HTML form file $g_name=mysql_real_escape_string($_POST['opp_team']); //This value has to be the same as in the HTML form file $sql="INSERT INTO form_data (your_team, opp_team, date, time, g_name) VALUES ('$your_team','$opp_team', '$date', '$time', '$g_name')"; /*form_data is the name of the MySQL table where the form data will be saved. name and email are the respective table fields*/ if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "Match Report has been added!."; mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
Adam Posted July 31, 2009 Share Posted July 31, 2009 You are trying to create the table without first specifying the database. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.