# A problem with this php file input form. I HAVE READ OTHER THREADS!

**URL:** <https://forum.kirupa.com/t/a-problem-with-this-php-file-input-form-i-have-read-other-threads/48015>\
**Category:** programming\
**Created:** [April 9, 2004, 2:29am UTC](https://forum.kirupa.com/t/a-problem-with-this-php-file-input-form-i-have-read-other-threads/48015 "2004-04-09T02:29:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamer](https://avatars.discourse-cdn.com/v4/letter/d/6bbea6/32.png) [@dreamer](https://forum.kirupa.com/u/dreamer)\
**Post date:** [April 9, 2004, 2:29am UTC](https://forum.kirupa.com/t/a-problem-with-this-php-file-input-form-i-have-read-other-threads/48015/1 "2004-04-09T02:29:49Z")

</div>

Please check this out:

```php

<?
$dbhost = "localhost"; 
$dbuser = "designers_hub"; 
$dbpwd = "";
$dbname = "shoppinglist"; 
$database = mysql_connect($dbhost, $dbuser, $dbpwd) or die ("Could not connect to mysql"); 
mysql_select_db("$dbname",$database) or die ("Could not select databases");

$id = $_POST['id'];
$name = $_POST['name'];
$description = $_POST['description'];
$stock = $_POST['stock'];
$cost = $_POST['cost'];
$payment_to = $_POST['payment_to'];
$image_name = $_POST['image_name'];
$image = $_POST['image'];

copy ($image, "images/$image_name");
chmod ("images/$image_name", 777);

mysql_query("INSERT INTO `items` (`id`,`name`,`description`,`stock`,`cost`,`payment_to`,`image_name`) VALUES ('$id','$name','$description','$stock','$cost','$payment_to',`$image_name`)");

mysql_close();

?>

```

What this does it upload the selected file to a directory and make a record on a mysql database. For some reason it moves the file but doesn’t add a record. When I take out the $image\_name and image\_name in the mysql\_query it works but then I can’t record on the database the file name. Can someone help\>
