Jump to content

tarleton

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Everything posted by tarleton

  1. They are Varchars, and it just leaves them blank
  2. Its just m_dat = -02/09/2009 and m_time = 4:15 PM
  3. Hi guys got a form I am making. At the moment what happens is the user runs the install script then enters details in the form which then posts data to formindb.php which inserts in a php table. At the moment everything works fine except the m_dat and m_tim fields do not get sent from the form to the database. Any ideas? Install <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create database if (mysql_query("CREATE DATABASE module",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } // Create table mysql_select_db("module", $con); $sql = "CREATE TABLE `module`.`form_data` (`your_team` VARCHAR(30) NOT NULL, `opp_team` VARCHAR(30) NOT NULL, `m_dat` VARCHAR(15) NOT NULL, `m_tim` VARCHAR(15) NOT NULL, `g_name` VARCHAR(30) NOT NULL, `result` VARCHAR(15) NOT NULL, `writeup` TEXT NOT NULL) ENGINE = MyISAM;"; // Execute query mysql_query($sql,$con) or trigger_error("Error in query: $sql <br>Error was:" . mysql_error(),E_USER_ERROR); mysql_close($con); ?> Form <!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=utf-8" /> <title>Match Report</title> <style type="text/css"> <!-- #match_report table tr td label { text-align: center; } --> </style> </head> <body> <form id="match_report" name="Match Report" method="post" FORM ACTION="formindb.php"> <table width="480" border="0"> <tr> <td colspan="2"><center><strong>Match Report</strong></center></td> </tr> <tr> <td width="176">Your Clan Name:</td> <td width="288"><input type="text" name="your_team" id="Team1" value="Your Clan Name" /></td> </tr> <tr> <td>Opposing Team:</td> <td><input type="text" name="opp_team" id="opp_team" value="Opposing Team Name"/></td> </tr> <tr> <td>Date of Match:</td> <td><input name="m_dat" type="text" id="m_dat" value="dd/mm/year" size="13"/></td> </tr> <tr> <td>Time of Match:</td> <td><input name="m_tim" type="text" id="m_tim" value="hh:mm PM" size="13"/></td> </tr> <tr> <td>Game Name:</td> <td><input type="text" name="g_name" id="g_name" value="Game Played"/></td> </tr> <tr> <td><label> </label> Result:</td> <td><input name="result" type="text" id="result" value="11-3" size="10"/></td> </tr> <tr> <td>Write Up:</td> <td><textarea name="writeup" id="writeup" cols="45" rows="5"></textarea></td> </tr> <tr> <td colspan="2"><label> <input type="submit" name="submit" id="submit" value="Submit" /> </label></td> </tr> </table> </form> </body> </html> Formindb.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create table mysql_select_db("module", $con); $your_team = mysql_real_escape_string($_POST['your_team']); $opp_team = mysql_real_escape_string($_POST['opp_team']); $m_tim = mysql_real_escape_string($_POST['m_tim']); $m_dat = mysql_real_escape_string($_POST['m_dat']); $g_name = mysql_real_escape_string($_POST['g_name']); $result = mysql_real_escape_string($_POST['result']); $writeup = mysql_real_escape_string($_POST['writeup']); $sql="INSERT INTO form_data (your_team, opp_team, m_dat, m_tim, g_name, result, writeup) VALUES ('$your_team','$opp_team','$m_dat','$m_tim','$g_name','$result','$writeup') "; // Execute query mysql_query($sql,$con) or trigger_error("Error in query: $sql <br>Error was:" . mysql_error(),E_USER_ERROR); mysql_close($con); ?> Any help appreciated.
  4. Ah thanks mate your a genuis SOLVED.
  5. Hi mate. Yea I read that after I posted, moved it after connection string however still no luck
  6. Thanks mate, still giving error: Fatal error: Error in query: INSERT INTO form_data (your_team, opp_team, date1, time1, g_name, result, writeup) VALUES ('','','','', ''. '', '') Error was:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '. '', '')' at line 2 in C:\xampp\htdocs\MODULE\formindb.php on line 35 <?php $your_team = mysql_real_escape_string($_POST['your_team']); $opp_team = mysql_real_escape_string($_POST['opp_team']); $time1 = mysql_real_escape_string($_POST['time1']); $date1 = mysql_real_escape_string($_POST['date1']); $g_name = mysql_real_escape_string($_POST['date1']); $result = mysql_real_escape_string($_POST['result']); $writeup = mysql_real_escape_string($_POST['writeup']); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create database if (mysql_query("CREATE DATABASE module1",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } // Create table mysql_select_db("module1", $con); $sql = "CREATE TABLE `module1`.`form_data` (`your_team` VARCHAR(30) NOT NULL, `opp_team` VARCHAR(30) NOT NULL, `date1` VARCHAR(15) NOT NULL, `time1` VARCHAR(15) NOT NULL, `g_name` VARCHAR(30) NOT NULL, `result` VARCHAR(15) NOT NULL, `writeup` TEXT NOT NULL, PRIMARY KEY (`your_team`)) ENGINE = MyISAM;"; $sql1="INSERT INTO form_data (your_team, opp_team, date1, time1, g_name, result, writeup) VALUES ('$your_team','$opp_team','$date1','$time1', '$g_name'. '$result', '$writeup') "; // Execute query mysql_query($sql,$con) or trigger_error("Error in query: $sql <br>Error was:" . mysql_error(),E_USER_ERROR); mysql_query($sql1,$con) or trigger_error("Error in query: $sql1 <br>Error was:" . mysql_error(),E_USER_ERROR); mysql_close($con); ?>
  7. by sanitize do u mean adding: $your_team=$_POST[result] at the begining of the page
  8. tal error: Error in query: INSERT INTO form_data (your_team, opp_team, date1, time1, g_name, result, writeup) VALUES ('','','','', ''. , ) Error was:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '. , )' at line 2 in C:\xampp\htdocs\MODULE\formindb.php on line 27 No idea what that even means. So new to php any idea?
  9. Thanks for that mate however no cigar, still not inporting into database here is my code again. FORM CODE <form id="match_report" name="Match Report" method="post" FORM ACTION="formindb.php"> <table width="480" border="0"> <tr> <td colspan="2"><center><strong>Match Report</strong></center></td> </tr> <tr> <td width="176">Your Clan Name:</td> <td width="288"><input type="text" name="your_team" id="Team1" value="Your Clan Name" /></td> </tr> <tr> <td>Opposing Team:</td> <td><input type="text" name="opp_team" id="opp_team" value="Opposing Team Name"/></td> </tr> <tr> <td>Date of Match:</td> <td><input name="date" type="text" id="date1" value="01/01/2009" size="13"/></td> </tr> <tr> <td>Time of Match:</td> <td><input name="time" type="text" id="time1" value="4:15 PM" size="13"/></td> </tr> <tr> <td>Game Name:</td> <td><input type="text" name="g_name" id="g_name" value="Game Played"/></td> </tr> <tr> <td><label> </label> Result:</td> <td><input name="result" type="text" id="result" value="11-3" size="10"/></td> </tr> <tr> <td>Write Up:</td> <td><textarea name="writeup" id="writeup" cols="45" rows="5"></textarea></td> </tr> <tr> <td colspan="2"><label> <input type="submit" name="submit" id="submit" value="Submit" /> </label></td> </tr> </table> formindb.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create database if (mysql_query("CREATE DATABASE module1",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } // Create table mysql_select_db("module1", $con); $sql = "CREATE TABLE `module1`.`form_data` (`your_team` VARCHAR(30) NOT NULL, `opp_team` VARCHAR(30) NOT NULL, `date1` VARCHAR(15) NOT NULL, `time1` VARCHAR(15) NOT NULL, `g_name` VARCHAR(30) NOT NULL, `result` VARCHAR(15) NOT NULL, `writeup` TEXT NOT NULL, PRIMARY KEY (`your_team`)) ENGINE = MyISAM;"; $sql1="INSERT INTO form_data (your_team, opp_team, date1, time1, g_name, result, writeup) VALUES ('$_POST[your_team]','$_POST[opp_team]','$_POST[time1]','$_POST[date1]', '$_POST[g_name]'. $_POST[result], $_POST[writeup]) "; // Execute query mysql_query($sql,$con); mysql_query($sql1,$con); mysql_close($con); ?>
  10. Perhahaps i should try and explain purpose of the script . Okay so what happens is a have a form where users enter a details from a Sport match. That form then sends data to this script which at creates a database and table then inserts form details. Eventually I hope to make it detect whethere a database already exists and if a table already exists and if it does to just insert the data from the form but haven't got their yet. So my problem atm is that it is not isnerting the data from the form. any ideas?
  11. Wow I never thought about that thanks mate great help but of course I get fronted by another problem, it now creates the database and table fine but fails in inporting data error is: Warning: Wrong parameter count for mysql_query() in C:\xampp\htdocs\MODULE\formindb.php on line 35 <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create database if (mysql_query("CREATE DATABASE module1",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } // Create table mysql_select_db("module1", $con); $sql = "CREATE TABLE `module1`.`form_data` ( `your_team` VARCHAR( 30 ) NOT NULL , `opp_team` VARCHAR( 30 ) NOT NULL , `date1` DATE NOT NULL , `time1` TIME NOT NULL , `g_name` VARCHAR( 30 ) NOT NULL , `result` VARCHAR( 15 ) NOT NULL , `writeup` TEXT NOT NULL ) ENGINE = MYISAM ; "; $sql1="INSERT INTO form_data (your_team, opp_team, time1, date1, g_name, result, writeup) VALUES ('$_POST[your_team]','$_POST[opp_team]','$_POST[time1]','$_POST[date1]', '$_POST[g_name]'. $_POST[result], $_POST[writeup]) "; // Execute query mysql_query($sql,$sql1,$con); mysql_close($con); ?>
  12. Hi PHPKNIGHT I considered that however I want this to do it automatically so every time someone uses the form they don't have to do it them selves.
  13. Hi guys got this script I'm working on. At the moment it creates the database fine however it doesn't create the table. Any ideas? <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } // Create database if (mysql_query("CREATE DATABASE module1",$con)) { echo "Database created"; } else { echo "Error creating database: " . mysql_error(); } // Create table mysql_select_db("module1", $con); $sql = "CREATE TABLE form_data ( your_team varchar(30), opp_team varchar(30), time1 varchar(15), date1 varchar(15), g_name varchar(30), )"; $sql1="INSERT INTO Persons (your_team, opp_team, time1, date1, g_name) VALUES ('$_POST[your_team]','$_POST[opp_team]','$_POST[time1]','$_POST[date1]', '$_POST[g_name]') "; // Execute query mysql_query($sql,$con); mysql_close($con); ?>
  14. 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); ?>
  15. 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); ?>
  16. Hi. I am tryin to make a script which is located in /public_html/class/script.php so it copies the folder /public_html/joomla/ to public_html/$username where $username is take from the file /public_html/class/include/cpanel.class.... Would $dir1 = .../joomla/ and $dir2 = .../class/include/cpanel.class.php ?
×
×
  • 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.