Hi,
I am trying to create an upload file system to my mysql database and I keep getting the same error message. Can you take a quick look and help please?
Thanks, Eric
HTML FORM
Code:
<form action="show.php" method="post" enctype="multipart/form-data">
IB2:
<input type=radio name="grade" value="IB2" />
<br />
IB1:
<input type=radio name="grade" value="IB1" />
<br />
FY:
<input type=radio name="grade" value="FY" />
<br />
Y2:
<input type=radio name="grade" value="Y2" />
<br />
Y1:
<input type=radio name="grade" value="Y1" />
<br />
<input type=file method=post enctype=multipart/form-data />
<input type=submit name="submitb" value="Upload File" />
</form>
PHP CODE (show.php)
PHP Code:
<?php
$TheGrade = $_POST['grade'];
$name = $_FILES['file']['name'];
$type = $_FILES['file']['type'];
$size = $_FILES['file']['size'];
$Server="xxxx";
$User="xxxx";
$Password="xxxx";
$Database="db1083186_Files";
if($TheGrade==IB2){
$gradetable="IB2FILES";
} elseif($TheGrade==IB1){
$gradetable="IB1FILES";
} elseif($TheGrade==FY){
$gradetable="FYFILES";
} elseif($TheGrade==Y2){
$gradetable="Y2FILES";
} elseif($TheGrade==Y1){
$gradetable="Y1FILES";
} else {
echo "Connection error: No grade submission";
$gradetable=null;
echo $gradetable;
}
$connection = mysql_connect($Server, $User, $Password);
if(!$connection){
die("Couldn't Connect" . mysql_error());
}
echo "Connection Working";
echo $TheGrade;
echo $name;
echo $type;
echo $size;
mysql_select_db($Database, $connection);
$query = "INSERT INTO " . $gradetable . " (name,type,size) VALUES (" . $name . "," . $type . "," . $size . ")";
$table = mysql_query($query,$connection) or die(mysql_error());
// echo "<table border='1'>";
// echo "<tr> <th>id</th> <th>name</th> </tr>";
// // keeps getting the next row until there are no more to get
// while($row = mysql_fetch_array( $query )) {
// // Print out the contents of each row into a table
// echo "<tr><td>";
// echo $row['id'];
// echo "</td><td>";
// echo $row['name'];
// echo "</td></tr>";
// }
// echo "</table>";
?>
ERROR MESSAGE:
Connection WorkingY1 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 1