Insert into database with form help

Here’s what index.php says[code]

Assignment: Teacher: Due: Subject: First name: <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); }

mysql_select_db(“my_db”, $con);

$result = mysql_query(“SELECT * FROM ecot”);

echo "

";

while($row = mysql_fetch_array($result))
{
echo “

”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
echo “”;
}
echo “
Assignments Teacher Due Subject Your name
” . $row[‘assignment’] . “” . $row[‘teacher’] . “” . $row[‘due’] . “” . $row[‘subject’] . “” . $row[‘name’] . “
”;

mysql_close($con);
?>[/code]

And here’s what add.php says, i get error here.
Parse error: syntax error, unexpected T_VARIABLE in F:xampphtdocsecotadd.php on line 11

[code]<?php
$con = mysql_connect(“localhost”,“root”,"");
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

mysql_select_db(“ecot”, $con);

mysql_query("INSERT INTO assignment (assignment,teacher,due,subject,name)) [/code]

Error line

VALUES ("$_POST[assignment]', '$_POST[teacher]', '$_POST[due]', '$_POST[subject]', '$_POST[name]")");

mysql_close($con); ?>

Edit: Found error, posting just incase someone else wants it

VALUES ("$_POST[assignment]’, ‘$_POST[teacher]’, ‘$_POST[due]’, ‘$_POST[subject]’, '$_POST[name]")");

should be

VALUES ($_POST[assignment]’, ‘$_POST[teacher]’, ‘$_POST[due]’, ‘$_POST[subject]’, '$_POST[name])");

Sponsor our Newsletter | Privacy Policy | Terms of Service