I wanto save my file by the name like this profile_img_(id generated while inserting this particular row in database ).png or any format .
for ex profile_img_1.png for first record on database table
profile_img_2.png for 2nd record resp and so on
How can I rename it to get this in above way ?
Typo again. What editor do you use for coding? I use Notepad++ and the colour highlighting shows up things like missing quotes (which you had in another thread).
But use prepared statements as @chorn said above. It’s time well spent.
You’re mixing up single and double quotes in that query. If you use double-quotes to surround the string, you don’t need the . either side of the variables you are trying to concatenate. If you var_dump() the query string, what does it show? You should see where it is wrong, but you’ll have to assign it to a string first rather than directly into the query function.
$query = "update account set upload = // ... and so on
var_dump($query);
$result = mysqli_query($conn, $query);
if ($result) { // ... and so on
But seriously, as people keep suggesting, take a few minutes to learn about prepared statements as this is another problem you wouldn’t be having if you used them. Why don’t you want to do that?
You haven’t read the article that @chorn pointed you to - one of the key features of a prepared statement is that you do not concatenate variables into the query string (which I believe is what is causing your problem). Instead you use placeholders for each parameter, and pass them in after you have called prepare(). I don’t have any sample code for mysqli as I use PDO myself.
I know it sounds like a deviation from the job at hand, but it’s worth it IMO.
And what happens?
ETA - now I’ve read it, that link isn’t all that strong on examples dealing with updating a table. The principles are there, but there’s a bit to change. As I read it you’d do something like:
$query = "upload mytable set upload = ? where id = ?";
$q = $conn->prepare($query);
$q->bind_param("ss", $uploadvalue, $idvalue); // assuming both are strings
$q->execute();
So you just need to set the appropriate values for the two variables in the bind_param() function to theoretically get it working.
What result is it getting? Please add more detail - it’s no good just saying “didn’t work” - you need to be more specific. Does it add something in that isn’t correct, or not update anything?