got no error but my data cant be inserted.what wrong with it
<?
function upload_form(){
global $PHP_SELF;
?>
<form name="add" method="post" action="<?php echo $PHP_SELF ?>" ENCTYPE="MULTIPART/FORM-DATA" >
<table width="792" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<div align="center">
<hr>
<font size="2" face="Arial, Helvetica, sans-serif"><b></b></font></div>
</td>
</tr>
<tr>
<td width="158">Partners Name</td>
<td width="317">
<input type="text" name="partners_name">
</td>
<td width="317"> </td>
</tr>
<tr>
<td valign="top" width="158">Image to be uploaded</td>
<td width="317">
<input type="file" name="userfile">
</td>
<td width="317" rowspan="2"> </td>
</tr>
<tr>
<td valign="top" width="158">URL</td>
<td width="317">
<input type="text" name="url">
</td>
</tr>
<tr>
<td valign="top">Writeup</td>
<td>
<textarea name="writeup" cols="50" rows="10"></textarea>
</td>
<td> </td>
</tr>
<tr>
<td width="158">
<input type="hidden" name="action" value="upload">
<input type="reset" name="Submit2" value="Reset">
<input type="submit" name="Submit" value="Upload">
</td>
</table>
<p> </p>
</form>
<?
}
/***************************** START OF FILE COPY & INSERTION TO DATABASE **********************************/
function upload(){
global $userfile, $userfile_name, $userfile_size, $userfile_type, $WINDIR, $partners_name,$url,$writeup;
//Attemp to check platform if Windows change to double back slash
if(isset($WINDIR)) $userfile = str_replace("\\\\","\\", $userfile);
$max_size = 65536;
//Read filename directory path and return filename only
$filename = basename($userfile_name);
//Check if its exceed $max_size
if ($userfile_size > $max_size)
die("File your trying to upload is exceed the upload quota");
//Check if filename & fields if empty
if (empty($partners_name)) die ("Please fill partners name field");
if($userfile_size <= 0) die ("Please browse an image file to upload");
if (empty($url)) die ("Please fill URL field");
if (empty($writeup)) die ("Please fill write-up field");
//Attempt to copy filename to temporary directory
if(!@copy($userfile, "temp/$filename"))
die("Can't copy $userfile_name to $filename");
//Attempt to delete temporary $userfile generated by PHP
if(!@unlink($userfile) )
die ("Can't delete the file $userfile_name.");
echo "File : $filename has been succcesfully uploaded. <BR>";
echo "Filesize : " . number_format($userfile_size) ."<BR>";
echo "Filetype : $userfile_type <BR><BR>";
//Attempt to connect to MySQL server
$link = mysql_connect("localhost","user","passwrod");
// If connection failed...
if (!$link) {
// Inform user of error and quit
print "Couldn't connect to database server";
exit;
}
// Attempt to select database
if(!@mysql_select_db(database_name)) {
// Inform user of error and exit
print "Couldn't select database <br>\n";
exit;
}
// Build Query
$image = addslashes(fread(fopen("temp/$filename","rb"), filesize("temp/$filename")));
if (!image) die ("Cannot open file");
//Get time
$posted = time();
//Set status
$stat = "Active";
//Build query
$query = "INSERT INTO partners VALUES(NULL,'$partners_name','$writeup','$url',$stat,'$image',$posted)";
echo $query."<br><br>";
// Execute Query
$result = mysql_query($query);
// Close the connection
//mysql_close($link);
}
/**********************************END OF FILE INSERTION TO DATABASE ***********************/
?>
<HEAD><TITLE>UPLOADING WINDOW</TITLE></HEAD>
<BODY>
<?
if ($action == 'upload')
upload();
else upload_form();
?>
</BODY>