Code: Select all
<?php
set_include_path("." . PATH_SEPARATOR . get_include_path());
require 'ArchiveExtractor.class.php';
// database code
$dbh=mysql_connect ("localhost", "root",
"") or die('Cannot connect to the database because: ' . mysql_error());
mysql_select_db ("wwwgodn_godnels");
echo "Connection Successfull";
$sql="SELECT fldUsername FROM tblusers where fldUsername='".$_POST["txtusername"]."'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
echo "Username already exists!!!";
exit(1);}
mysql_free_result($result);
$rs = @mkdir( $_POST["txtusername"], 0777 );
echo "make directory sucessfull";
if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "application/x-rar-compressed")|| ($_FILES["file"]["type"] == "application/rar")
|| ($_FILES["file"]["type"] == "application/octet-stream")|| ($_FILES["file"]["type"] == "application/zip")
||($_FILES["file"]["type"] == "application/x-zip-compressed")||($_FILES["file"]["type"] == "application/octet-stream")
||($_FILES["file"]["type"] == "application/x-compress")||($_FILES["file"]["type"] == "application/x-compressed")
||($_FILES["file"]["type"] == "multipart/x-zip")|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 2000000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
//echo "Upload: " . $_FILES["file"]["name"] . "<br />";
//echo "Type: " . $_FILES["file"]["type"] . "<br />";
//echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
//echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists($_REQUEST["txtusername"]. "/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{move_uploaded_file($_FILES["file"]["tmp_name"],
$_REQUEST["txtusername"]."/" . $_FILES["file"]["name"]);
echo "Stored in: " . $_REQUEST["txtusername"]."/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
if ((($_FILES["file"]["type"] == "application/zip")
|| ($_FILES["file"]["type"] == "application/rar")
|| ($_FILES["file"]["type"] == "application/zip")
||($_FILES["file"]["type"] == "application/x-zip-compressed")
||($_FILES["file"]["type"] == "application/octet-stream")
||($_FILES["file"]["type"] == "application/x-compress")
||($_FILES["file"]["type"] == "application/x-compressed")
||($_FILES["file"]["type"] == "multipart/x-zip")
|| ($_FILES["file"]["type"] == "application/octet-stream")))
{
$archExtractor=new ArchiveExtractor();
$extractedFileList=$archExtractor->extractArchive($_REQUEST["txtusername"]."/" . $_FILES["file"]["name"],$_REQUEST["txtusername"]."/");
chmod($_POST["txtusername"]."/" . $_FILES["file"]["name"],0777);
unlink($_POST["txtusername"]."/" . $_FILES["file"]["name"]);
echo "album submitted";
}
$sql="Insert Into tblusers (fldUsername,fldPassword) Values ('".$_POST["txtusername"]."','".$_POST["txtpassword"]."')";
$result = mysql_query($sql);
mysql_close($dbh);
?>here's the error i get
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\TEST\upload.php on line 16
Warning: mysql_free_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\TEST\upload.php on line 20
Secondly the data is not inserted into the database. but the new directory with user name is created and the zip file is uploaded and extracted to that folder. but archive file is not deleted after extraction of the file is done.
and the user id and password are not added to the database table