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
https://forums.phpfreaks.com/topic/168272-parse-error-newbie/
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
https://forums.phpfreaks.com/topic/168272-parse-error-newbie/#findComment-887572
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.