Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
am trying to associate username and filename in my database.basically
am trying to create a script when users upload a file the file is then
associated with the user in the when the user logon into
his account the database brings forward to file he or she uploaded.

I get this notice:

Notice: Undefined index: filename in /home/fhlinux169/c/
user/htdocs/upload.php on line 47
Could not insert data because Column count doesn't match value count
at row 1

this is the script. Am really stuck at the moment any help will be

$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$table=""; // Table name
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;

//This is our size condition
$upload_size = $_FILES['uploaded']['size'];
if ($upload_size > 1000000000000)
echo "Your file is too large.<br>";

//This is our limit file type condition
$upload_type = $_FILES['uploaded']['type'];
if ($upload_type =="text/php")
echo "No PHP files<br>";

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
Echo "Sorry your file was not uploaded";

//If everything is ok we try to upload it
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
echo "The file ".
basename( $_FILES['uploaded']['name']). " has been uploaded";
$filename=basename( $_FILES['uploaded']['name']);

mysql_connect("$host", "$username", "$password")or die("cannot
mysql_select_db("$db_name")or die("cannot select DB");
$sql="update $table set filename = '$filename' WHERE
username='session_is_registered('username')' ";

$insert = mysql_query("insert into $table values ('NULL','".
or die("Could not insert data because ".mysql_error());

echo "Sorry, there was a problem uploading your file.";

<a href="/user.php">Return to User Page</a> </form>

Re: Newbieeeee

Show us your html form.

Where are you getting $_POST['filename'] from?

Re: Newbieeeee

Reggie wrote:
Quoted text here. Click to load it

Additionally, you have a SQL problem which you should follow up in  

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Site Timeline