I've got a form, which seems to behave itself and sends data to PHP, which should then write a new row in MySQL.
- Code: Select all
<?php
INCLUDE 'conn.php';
$compfore = $_REQUEST["compfore"];
$compsur = $_REQUEST["compsur"];
$sex = $_REQUEST["sex"];
$nation = $_REQUEST["nation"];
$query = "INSERT INTO competitor (forename, surname, sex, nationality)
VALUES ($compfore, $compsur, $sex, $nation)";
$result = mysql_query($query, $conn) or die(mysql_error());
?>
- Code: Select all
<?php
$server = "localhost";
$user = "user";
$pwd = "pwd";
$dbn = "db";
$conn = mysql_connect($server, $user, $pwd) or die(mysql_error());
mysql_select_db($dbn);
?>
I'm getting errors on line 2 (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), which is just confusing because there is no ')' on line 2
I also managed to fix that and get an error down the bottom before I broke the top again
Is there something dreadfully wrong with my syntax? Can't work it out, as is abundantly obvious, I'm a total newbie, so it's probably all wrong...
Thanks!
