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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:10:18+00:00 2026-05-12T07:10:18+00:00

I have no idea why this won’t work. function query($sql) { $this->result = @mysql_query($sql,

  • 0

I have no idea why this won’t work.


function query($sql) {

     $this->result = @mysql_query($sql, $this->conn);

     return($this->result != false);

}

function convert() {
$this->db->open();
$sql_update = "";
$this->db->query("SELECT * FROM ACCOUNTS ");
$str = '';
while ($row = $this->db->fetchassoc()) {
$jobNum = $row['JOBNUMBER'];
$old_date = $row['INSTALLDATE'];
$new_date = date("Y-m-d", strtotime($old_date));
$sql_update = "UPDATE ACCOUNTS SET INSTALLDATE='$new_date' WHERE JOBNUMBER='$jobNum' ";
//$this->db->query($sql_update) or die($this->response->throwResponseError(MSG_DATABASE_ERROR . mysql_error()));
$str .= $jobNum . " -- " . $new_date . "
";
}

    return $str;
}

If I run it with that line commented out, it returns all the results i want. But when I uncomment the line where it actually runs the update, it updates the first record and stops the loop. Why?

  • 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-12T07:10:18+00:00Added an answer on May 12, 2026 at 7:10 am

    When you run update, it invalidates the hidden statement hander in your db and the results associated with it.

    db->query("SELECT …") -- creates the handler
    
    -- 1st iteration
    db->fetchassoc() -- fetches the first row
    db->query("UPDATE …") -- creates another handler and destroys the old one
    
    -- 2nd iteration
    db->fetchassoc() -- no rows returned by `UPDATE`, nothing to fetch
    

    What you are trying to do, can be done more easily using a single statement:

    UPDATE  accounts
    SET     installed = DATE_FORMAT(STR_TO_DATE(installed, @current_format_string), '%Y-%d-%m')
    

    , where @current_format_string is how your dates are formatted now.

    Update:

    Try running this query:

    UPDATE  accounts
    SET     installdate = DATE_FORMAT(STR_TO_DATE(installdate , '%m/%d/%Y'), '%Y-%d-%m')
    

    Before you run UPDATE query, you may want to check the results with SELECT:

    SELECT  DATE_FORMAT(STR_TO_DATE(installdate, '%m/%d/%Y'), '%Y-%d-%m')
    FROM    accounts
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 168k
  • Answers 168k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You must profile your process before making any decisions. Where… May 12, 2026 at 1:42 pm
  • Editorial Team
    Editorial Team added an answer You're publishing to a sub directory (PhoneControl) of the application… May 12, 2026 at 1:41 pm
  • Editorial Team
    Editorial Team added an answer I posted this question because I had a model with… May 12, 2026 at 1:41 pm

Related Questions

I have no idea why this won't work. function query($sql) { $this->result = @mysql_query($sql,
I have a request for a contracting gig and one of the requirements in
On my work computer, debugging in Visual Studio 2008 (SP1) seems to work somewhat
Racking my brains on this one. I have the code below: the first stages
I need to build a simple webservice to get data in and out of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.