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

  • SEARCH
  • Home
  • 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 5964583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:27:33+00:00 2026-05-22T19:27:33+00:00

I am using uploadify to upload pictures into server . Back end I am

  • 0

I am using uploadify to upload pictures into server . Back end I am using PHP script . In PHP script I am inserting the file location and some other details in database in addition to copying to target location .

Problem :- If I am uploading 20 files , the PHP script is getting called 20 times and the database insert statement are getting called 20 times to insert for different images . Definitely calling database 20 times is inefficient way of doing it . Is there any way I can hold the file names( and location) and call the insert statement (in the end) only once to insert all the 20 records at once ?

Thanks for your help

Regards

Kiran

  • 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-22T19:27:34+00:00Added an answer on May 22, 2026 at 7:27 pm

    One approach I recommend for this is the use of a prepared statement through the mysqli extension. To quote on the main advantage:

    The actual purpose to use a prepared
    statement in sql is to cut the cost of
    processing queries; NOT to separate
    data from query. That’s how it’s being
    used w/ php NOW, not how it was
    designed to be used in the first
    place. With SQL you cut the cost of
    executing multiple similar queries
    down by using a prepared statement..
    Doing so cuts out the parsing,
    validation and most often generates an
    execution plan for said query up
    front. Which is why they run faster in
    a loop, than their IMMEDIATE Query
    cousins do.

    Source: https://www.php.net/manual/en/mysqli.prepare.php#103730

    To give an example on how you can utilize this:

    $mysqli = new mysqli("localhost", "my_user", "my_password", "world");
    
    /* check connection */
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }
    
    if ($stmt = $mysqli->prepare("INSERT INTO `images` (`location`, `size`, `othervalues`) VALUES(?, ?, ?)")) {
      foreach($images as $image) {
        // s = string value
        // i = integer value
        $stmt->bind_param("sis", $image['location'], $image['size'], $image['othervalues']);
        $stmt->execute();
      }
      $stmt->close();
    }
    // Your prepared statement failed, handle the error
    else {
    }
    
    $mysqli->close();
    

    I’d recommend reading up on mysqli::prepare and mysqli_stmt::bind_param for more information on how the process works. I also recommend reading up on prepared statements in the MySQL documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to upload files to server using Uploadify script and then show them
I'm using uploadify (a jQuery uploading) script, which has basically a PHP file at
I am currently looking in to some file uploading using Java Server Faces. I've
I use Uploadify to upload multiple pictures to server. I want to display pictures
I am using uploadify plugin to upload images. On some browsers uploadify button is
I am using Jquery Uploadify for images upload with PHP, here i have multiple
I am using Jquery Uploadify for images upload with PHP, here i want to
I'm using Uploadify to upload some images with ASP.NET. I use Response.WriteFile() in ASP.NET
I am using uploadify along with ASP.NET to upload files to my server. At
I'm using Uploadify and Kohana and I'm creating file uploader. User can upload only

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.