0

I'm coding a registration form that includes a file upload field. Basically, there are two queries that need to be simultaneously inserted into a database. But unfortunately, I don't know how to do it. So, I need your help.

if ($my_upload->upload()) { // new name is an additional filename information, use this to rename the uploaded file

            query(sprintf("INSERT INTO users SET userimage = '%s'", $my_upload->file_copy));

        }

        }



        // end of file upload part



        if (!empty($_POST["username"]))

        {

            $result = query("INSERT INTO users (firstname, lastname, username, usersex, hash, email) VALUES (?, ?, ?, ?, ?, ?)",

            $_POST["firstname"],

            $_POST["lastname"],

            $_POST["username"],

            $_POST["usersex"],

            crypt($_POST["password"]),

            $_POST["email"]);
        }

Edited by mexabet: grammar correction

2
Contributors
6
Replies
23
Views
3 Years
Discussion Span
Last Post by mexabet
0

Thanks for replying. query() is a custom function that executes SQL statement, possibly with parameters, returning an array of all rows in result set or false on (non-fatal) error.

0

I don't see why those two queries should be inserted simultaneously, but either use a transaction, or MySQLi's multi_query.

0

Sorry, but I don't know how to do InnoDb transactions or MySQLi's multi_query. Can you please, guide me on how to achieve InnoDB transactions? I'd appreciate that.

1

Thanks for the link. I'm going through the resource to see if I can pull it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.