Trying to build a script to upload images to a server along with a description...
But getting
Warning: Unable to create '/home/httpd/vhosts/site1/httpdocs/images/fans/': Is a directory in /home/httpd/vhosts/site1/httpdocs/admin/admin.php on line 61
Warning: Unable to move '/tmp/phpIh7va1' to '/home/httpd/vhosts/site1/httpdocs/images/fans/' in /home/httpd/vhosts/site1/httpdocs/admin/admin.php on line 61
Warning: Access denied for user: 'apache@localhost' (Using password: NO) in /home/httpd/vhosts/site1/httpdocs/admin/admin.php on line 69
Warning: MySQL Connection Failed: Access denied for user: 'apache@localhost' (Using password: NO) in /home/httpd/vhosts/site1/httpdocs/admin/admin.php on line 69
Unable to connect!
Here is the code I am using to determine if this is a new update
Code: Select all
@mysql_connect($host, $loginname, $password) or die(mysql_error());
@mysql_select_db($db) or die('Could not select database<br />'.mysql_error());
if ($_SERVERї'REQUEST_METHOD']=='GET'){
?>But on submit this is the code I am trying to use
Code: Select all
<?
} else {
$tmp_loc=$_FILESї'pic']ї'tmp_name'];
$name=$_FILESї'pic']ї'desciption'];
move_uploaded_file($tmp_loc, "/home/httpd/vhosts/site1/httpdocs/images/$directory/$name");
$errorList = array();
$count = 0;
if (!$tmp_loc) { $errorListї$count] = "Invalid entry: File"; $count++; }
if (sizeof($errorList) == 0) {
$connection = mysql_connect() or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");
$query = "INSERT INTO image(pic) VALUES('$pic', NOW())";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
echo "<font size=-1>Added successfully.</font>";
mysql_close($connection);
} else {
echo "<font size=-1>The following errors were encountered: <br>";
echo "<ul>";
for ($x=0; $x<sizeof($errorList); $x++)
{
echo "<li>$errorListї$x]";
}
echo "</ul></font>";
}
}
?>Thanks