Can anyone see whats wrong with this
PHP code?!!
Ive been told its down to permission problems as i just get the error message thats in the else statement.
But ive set all of the permissions so full and im still having the same problem.
- PHP: Select all
include "conn.php";
//rename file
$sql=mysql_query("SELECT num FROM num");
if(!$sql)
{ echo mysql_error();
}
else {
$num=mysql_result($sql, 0, 0);
echo 'num is '.$num.'<p>';
$num++;
}
//set directory
$target="Images/pics/";
$target=$target.$num.'.jpg';
$mode=0777;
chmod($target, $mode);
$res=mysql_query("UPDATE num SET num = $num");
//check dimensions and filetype, 200px and jpg
$tmpname=$_FILES['file']['tmp_name'];
$size=getimagesize($tmpname);
$filetype=$size[2];
if($filetype!=2)
{
echo "ERROR: All images must be a .jpg";
}
//transfer file and insert into databases
elseif(move_uploaded_file($_FILES['file']['tmp_name'], $target))
{
$name=$num;
$select=$_POST['select'];
$pic=$_POST['pic'];
$res=mysql_query("UPDATE gallery SET $pic='$name' WHERE name = '$select'");
if(!$res)
{
echo '<p>'.mysql_error();
}
echo mysql_affected_rows($res).'<p>Image '.$name.'.jpg uploaded to '.$select.' '.$pic;
}
else
{
echo 'error';
}