Jump to content

Recommended Posts

I want to save some info along with two pictures the problem is that nothing is saving in the database
my error message is

Warning: Wrong parameter count for move_uploaded_file()

PLEASE HELP!!!
[code=php:0]

define ("$uploaddir", "/home/townsfin/public_html/business_images/");


$uploadfile1 = $_FILES['Picture1']['name'];

if(isset ($_FILES['Picture1']))
{

If (is_uploaded_file($_FILES['Picture1']['tmp_name'])&&
is_uploaded_file($_FILES['Picture2']['tmp_name']));
{

  $fullpath1 = $uploaddir . $uploadfile1;
$today=date("m-d-y");

$filename1=$_POST['name']. "1";

$result= move_uploaded_file($_FILES['Picture1']['tmp_name'],  $uploaddir .$filename1);
}
if($result==1)
{

  echo"picture one uploaded";
}

$uploadfile2= $_FILES['Picture2']['name'];
$fullpath2=$uploaddir . $uploadfile2;

$filename2= $_POST['name']. "2";
$result = move_uploaded_file($_FILES['Picture2']['tmp_name'], $uploaddir .$filename2);

print_r($_FILES);


  if ($result==1)

  {

  echo"Picture2 uploaded";

}
  // this is the line where i am getting error
  if (move_uploaded_file($_FILES['Picture2']['tmp_name']. $uploaddir .$filename2) && ($_FILES['Picture1']['tmp_name']. $uploaddir .$filename1))

{


  $sql="INSERT INTO `business_info`(`BusinessName`,`Slogan`,`Business_Address`,`Tel`,`Website`,`Email`,
`Fax`,`type`,`make`,`Categories`,`Keyword`,`Picture1`,`Headline`,`Slogan2`,`Description1`,`Description2`,`Description3`,
`Picture2`,`Picture3`,`User_Name`,`Password`)

Values('$BusinessName','$Slogan','$Business_Address','$Tel','$Website','$Email','$Fax','$type','$make','$Categories','$Keyword',
'$fullpath1','$Headline','$Slogan2','$Description1',
'$Description2','$Description3','$fullpath2','$fullpath1','$User_Name','$Password')";
  mysql_query($sql)or die(mysql_error());
}

}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/35371-not-saving-record-in-the-database/
Share on other sites

This...

[code=php:0]define ("$uploaddir", "/home/townsfin/public_html/business_images/");[/code]

should be....

[code=php:0]
define ("UPLOADDIR", "/home/townsfin/public_html/business_images/");
[/code]

then change every instance of $uploaddir to UPLOADDIR in your script. Constants don't use $, and it is also good practice to capitalize them so they stand out.
<form  enctype="multipart/form-data" action="insert_data.php" method="Post">
<input name="Picture1" type="file" value="">

   
  </td>
        </tr>
        <tr>
          <td>Picture 2
  <input name="Picture2" type="file" value="">
  </td>
I changed $uploaddir to UPLOADDIR and still i keep getting the same message on the same line
[code=php:0]
 
  if (move_uploaded_file($_FILES['Picture2']['tmp_name']. UPLOADDIR .$fullpath1) && ($_FILES['Picture1']['tmp_name']. UPLOADDIR .$fullpath2))

[/code]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.