> got a problem here people. > What I want to do is upload a file and store its name in a database. > For some reason I cant.
What version of php are you using? Did you check the register_globals in php.ini??? O...in the process script, you have $usefile, but in the submit script, it's $useRfile If register_globals is On, then skip the "Change to:" parts > Process the form: > <? > require("../Cart.php"); > Root(); > DBinfo(); > > mysql_connect("$DBHost","$DBUser","$DBPass"); > $UploadURL = "../images/"; > if ($usefile=="none") Change to: if ( $_FILES['userfile']['name'] == "none" ) or if ( is_uploaded_file( $_FILES['userfile']['tmp_name'] ) ) > { > echo "Error: no file uploaded"; > exit; > } > //Connect to DB > $mysql = mysql_connect("$DBHost","$DBUser","$DBPass"); > if(!$mysql) > { > echo "Cannot connect to database."; > exit; > } > > mysql_query("INSERT INTO Items (ImageName) WHERE ItemID = '$II' > VALUE('test')"); This query is wrong. An insert query can't have a WHERE clause...check the MySQL documentation about that. > > $upfile = "$UploadURL".$userfile_name; Change to: $upfile = $UploadUrl . $_FILES['userfile']['name'] > if ( !copy($userfile, $upfile)) Change to: if ( !copy( $_FILES['userfile']['tmp_name'], $upfile ) ) OR if ( !move_uploaded_file( $_FILES['userfile']['tmp_name'], $upfile ) ) > { > echo "Error: Could not move file into directory"; > exit; > } > ?> HTH Erwin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php