Alright this is my code, the error im getting is in red

<?php

include("dbinfo.inc.php");

$tut_name     = $_POST['tut_name'];
$tut_link     = $_POST['tut_link'];
$tut_program  = $_POST['tut_program'];
$tut_category = $_POST['tut_category'];
$tut_video    = $_POST['tut_video'];
$tut_download = $_POST['tut_download'];
$tut_image    = $_FILES['tut_image']['name'];

function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

if (empty($tut_image)) {
	$result = '<font color=FFFFFF>Please choose a photo to upload</font>';
	$error++;
}
else {
		$filename = stripslashes($tut_image);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "jpg") && ($extension !== "jpeg") && ($extension !== "png") && ($extension !== "gif")) {
			$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['tut_image']['tmp_name'];
			$size = getimagesize($tmpFile);
			$sizekb = filesize($tmpFile);
			if ($sizekb > 10000) {
				$result = '<font color=FFFFFF>The image has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$imageName = '../images/tutorials/' . time() . '.' . $extension;
				$copy = copy($tmpFile, $imageName);
				if (!$copy) {
					$result = '<font color=FFFFFF>Image upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {
	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `tutorials` VALUES ('','$tut_name','$tut_link','$tut_program','$tut_category','$tut_video','$tut_download','$imageName')";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());
}

mysql_close();

?>

I have also CHMODed my file destination to 777 permision

I'm not 100% sure (just woken up and skimmed the code) but arent you trying to convert a directory into a file on your copy command?

Also i believe there is an image part of the multi dimensional array that is the bit you need to copy, not just the name.

If not then ignore the post and i will wake up and try again :P

i look over my code again and i can't see the problem. i have used this code a dozen times and never had a problem with it. are you sure its not the server.

try this:

<?php

include("dbinfo.inc.php");

$tut_name     = $_POST['tut_name'];
$tut_link     = $_POST['tut_link'];
$tut_program  = $_POST['tut_program'];
$tut_category = $_POST['tut_category'];
$tut_video    = $_POST['tut_video'];
$tut_download = $_POST['tut_download'];
$tut_image    = $_FILES['tut_image']['name'];

function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}

if (empty($tut_image)) {
	$result = '<font color=FFFFFF>Please choose a photo to upload</font>';
	$error++;
}
else {
		$filename = stripslashes($tut_image);
		$extension = getextension($filename);
		$extension = strtolower($extension);
		if (($extension !== "jpg") && ($extension !== "jpeg") && ($extension !== "png") && ($extension !== "gif")) {
			$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
			$error++;
		}
		else {
			$tmpFile = $_FILES['tut_image']['tmp_name'];
			$sizekb = filesize($tmpFile);
			if ($sizekb > 10000) {
				$result = '<font color=FFFFFF>The image has exceeded the size limit, please try again</font>';
				$error++;
			}
			else {
				$imageName = 'images/tutorials/' . time() . '.' . $extension;
				$copy = copy($tmpFile, $imageName);
				if (!$copy) {
					$result = '<font color=FFFFFF>Image upload unsuccessful, please try again</font>';
					$error++;
				}
			}
		}
}
if ($error > 0) {
	echo $result;
}
else {
	$con = mysql_connect('localhost',$username,$password);
	@mysql_select_db($database) or die( "Unable to select database");
	$sql = "INSERT INTO `tutorials` VALUES ('','$tut_name','$tut_link','$tut_program','$tut_category','$tut_video','$tut_download','$imageName')";
	$query = mysql_query($sql) or die('Error: ' . mysql_error());
}

mysql_close();

?>
commented: For helping mt out again =D +1

Thanks kkiehth29, but again another problem, heres what I get. Error: Column count doesn't match value count at row 1 Edit: nvm it works now, thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.