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 695773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:59:38+00:00 2026-05-14T02:59:38+00:00

I have three update statements to be executed in PHP, i am getting the

  • 0

I have three update statements to be executed in PHP, i am getting the values of all these as return parameters. How to execute each statement independely and finally show the end user the result that it has been successfully updated.

<?php 

        public function name($parameter1,$parameter2.... $parametern) {


        }

 ?>

Then how finally we can get the result in my row object.

  • 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-14T02:59:38+00:00Added an answer on May 14, 2026 at 2:59 am

    Ah i think i see, well looks to me from your update statements that you want to update 3 different tables which all depend on ‘tycodashboard’.

    In that case i advise you use transactions to retain a bit of data integrity, otherwise say if one fails? you’ll have lost some data. As a general rule, if you need to do more than 1 update simultaneously use transactions.

    Heres a great article on the subject: http://dev.mysql.com/doc/refman/5.0/en/commit.html

    Its quite easy to do, just make you sure your tables are using the INNODB, then all you have to do is append START TRANSACTION to the top of your sql script and then COMMIT at the end.

    You might be trying to combine too much into a single function, whenever i’m updating multiple tables, it’s easier to just handle each one in turn, rather than trying to stuff them all into one return. So try making a function that saves it, returning success or failure, then call it from your main function for each one of your sql scripts passing in the values.

    //This is the function that gets called from your page.
    public function my_called_function() {
    
        //your sql script (using "" means you can put variables in without having to remove the quotes)
        $sql = "UPDATE....SET 'col' = $_POST['myvalue']";
    
        //Run your script and get result
        $result = $this->save_my_stuff($sql);
    
        //if not null means success!
        if($result) {
            echo 'success!'; // your success message
        }
        else {
            echo 'something bad happened'; //your failure message
        }
    }
    
    //this is the function that does the saving!
    private function save_my_stuff($sql_script) {
    
        //Make connection
        $conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
        //Check connection
        if(!$conn) {
            //connection failed
            die('Could not connect: '.mysql_error());
        }
    
        //Select your database using your connection object
        mysql_select_db(DB_NAME, $conn);
    
        //try and save
        try {
            //run the query
            $result = mysql_query($sql_script, $conn);
    
            //return the result
            return mysql_result($result);
        }
        catch (Exception $e) {
            //deal with exception
            return null;
        }
    
        //close connection
        mysql_close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a (very simple and standard) UPDATE statement which works fine either directly
I have a lot of SQL insert/update/delete statements of which some are redundant. For
I have a bunch of SQL statements to execute on a database. (I'm doing
I have a tsql code ,which is basically bunch of insert and update statements
I have two complicated PHP objects, each of which has data in a few
I have two panels in update panel. In panel1, there is button. If I
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three models: class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through =>
I have three unordered lists that have been created as Scriptaculous Sortables so that

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.