Jump to content

Parse Error - Newbie


tarleton

Recommended Posts

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);
?>

Link to comment
Share on other sites

Hi guys managed to fix that problem seems I fail to copy files from dir to my server dir :o. 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);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.