Hi,
I'm working on renaming a file on upload. My idea was to take the users name and add the primary key number for the name of their profile picture. I have already screened the file for size, extension and illegal characters in the name. I'm having trouble getting mysql_fetch_assoc to give me a value besides array. So here is the crux of the issue:
$query = 'SELECT \'index\' FROM mytable WHERE username =\''.$username.'\'';
$result = mysql_query($query);
$index = mysql_fetch_assoc($result);
// then we use it
$new_name = '../profile_pics/'.$username.$index['index'].'.'.$ext.'';
outputs for example:
'adminArray.jpg'
and when I use $new_name to rename the file uploaded you get this in the folder:
adminindex.jpg
From the query, index is the primary key, which is set to auto increment. I realize this seems like an arbitrary naming scheme, but it was simply an exercise for me, which has proven more difficult than I had hoped. I thought if in the returned assoc. array if I called for the index column, I could access it with $index['index'] and I would get the value. I appreciate any help tremendously. Thanks.