Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1046985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:13:59+00:00 2026-05-16T16:13:59+00:00

The page has to INSERT a row and MAKE a directory with the name

  • 0

The page has to INSERT a row and MAKE a directory with the name of the ID of that row when the user clicks the upload button, will this script work?, what could possibly go wrong?.

(when the upload button has been clicked)
//insert the new row
$query=”INSERT
INTO photoalbum (userid) VALUES
($userid)”;
mysql_query($query);

//get the id of that row to make a
directory with that name
$getid=”SELECT
id FROM photoalbum WHERE userid =
$userid order by id desc limit 1″;
$result=mysql_query($getid);
$thename=mysql_results($result,0,”id”);
mkdir(‘userimages/$userid/photoalbums/$thename’);

{ script that upload the files in the new folder }

Is it safe to INSERT and SELECT the row I just inserted in the same page, just right after an insert has been done? I was thinking what if the SELECT query don’t pick the row i just inserted but instead the previous row, because the INSERT isnt fast enough and the SELECT query gets the previous row instead. Is this a possible scenario?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:14:00+00:00Added an answer on May 16, 2026 at 4:14 pm

    Why not use mysql_insert_id() ?

    As for your question if the insert is successful, then there is no problem with doing a select even a millisecond after the insert.

    I just noticed another problem:

    mkdir('userimages/$userid/photoalbums/$thename');
    

    Due to single quotes the $userid and $thename variables will be used literally, so instead use double quotes like this:

    mkdir("userimages/$userid/photoalbums/$thename");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This Wikipedia page has an extensive list of hashing methods As you can see,
I have a page that has an iframe From one of the pages within
Given an HTML page that has a complex table-based layout and many tags that
I have small page which has label, DropDownList and a submit button. <div> <asp:label
I have a Page that has a single instance of a UserControl that itself
I have a login page that has several textboxes on the page, one of
I'm working on a page has an ol with nested p's, div's, and li's.
I want to disable Javascript once a page has already loaded. Why? Because I
Is there any way I can detect when my page has been set as
I have a page which has a rectangular area with text and icons in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.