I try to create a new folder for each new registration but I do have troubles with naming them after their unique registration id.
In my database each new user gets a userid. To select the latest userid I use the SQL Statement
$sql = "SELECT max(userid) FROM User";
So far so good, PHPMYADMIN shows me the correct result, but I don't know how to save this single result in a variable in PHP. Read through the PHP manual and tried the different fetch options but either I didn't get it or the result was different from what I wanted.
Right now I can only print all the results, but not the one I want with this:
foreach ($db->query($sql) as $row) {
echo $row['userid'] . "<br />";
}
The goal is to get this thing to work:
mkdir("uploads/$userid", 0755, true);
Any help would be appreciated. I'm getting really frustrated with this!
EDIT:
Okay went for the easy route and named the directory after a hash from the email.
Still it would interest me:
If I use $sql = "SELECT max(userid) FROM User";
How do I bind the result to a variable in PHP?