Loading ...
Sorry, an error occurred while loading the content.
 

Why more than one update query is not running in php

Expand Messages
  • bhavna_coolinus
    Hi, I am calling some function consicutively each func having update query... but some update query not running in php, if i run same query un phpMyadmin it
    Message 1 of 5 , Jun 19 1:20 AM
      Hi,

      I am calling some function consicutively each func having update
      query...

      but some update query not running in php, if i run same query un
      phpMyadmin it runs properly...
      I can't update table using one update query bcoz i have to fech
      table agin and again after finishing one update..

      its like i am calling three functions like

      $today = getPresent($dblink,$id,$date);
      echo "<pre>";print_r
      ($today);echo "</pre>";
      if(count($today) > 0)
      {
      sleep(1);

      changeInOutTime($dblink,$id,$inTime,$outTime,$date,$today);
      sleep(1);

      $afterFirst= "";
      $afterFirst
      = getPresent($dblink,$id,$date);

      echo "<pre>";print_r($afterFirst);echo "</pre>";

      deductCoffeeTime
      ($dblink,$id,$inTime,$outTime,$date,$afterFirst);
      sleep(1);

      $afterSecond= "";
      $afterSecond
      = getPresent($dblink,$id,$date);

      echo "<pre>";print_r($afterSecond);echo "</pre>";

      deductLunchTime
      ($dblink,$id,$inTime,$outTime,$date,$afterSecond);
      }

      and its output comes like

      Array
      (
      [0] => 6
      [ID] => 6
      [1] => 2
      [EMPLOYEE_ID] => 2
      [2] => 2007-06-16
      [UPDATE_DATE] => 2007-06-16
      [3] => OUT
      [IN_OUT] => OUT
      [4] => 15:00:00
      [IN_TIME] => 15:00:00
      [5] => 16:00:00
      [OUT_TIME] => 16:00:00
      [6] => 00:20:00
      [TOTAL_TIME] => 00:20:00
      [7] => 03:34:02
      [FLEX_TIME] => 03:34:02
      [8] => 03:52:24
      [FLEX_BALANCE] => 03:52:24
      [9] => 00:00:00
      [NORM] => 00:00:00
      [10] => 02:20:00
      [DIFF] => 02:20:00
      [11] => 0
      [OVERTIME_FLAG] => 0
      [12] => 00:00:00
      [OVERTIME_50] => 00:00:00
      [13] => 00:00:00
      [OVERTIME_100] => 00:00:00
      [14] => 0
      [UPDATE_BY_ADMIN] => 0
      [15] => 07:26:26
      [FLEX_TOTAL] => 07:26:26
      )

      update daily_timerecord set DIFF=SUBTIME('00:20:00',SUBTIME
      ('16:00:00','12:00:00'),IN_TIME='12:00:00',OUT_TIME='16:00:00',TOTAL_
      TIME=SUBTIME('16:00:00','12:00:00') where EMPLOYEE_ID=2 and
      UPDATE_DATE='2007-06-16'

      Array
      (
      [0] => 6
      [ID] => 6
      [1] => 2
      [EMPLOYEE_ID] => 2
      [2] => 2007-06-16
      [UPDATE_DATE] => 2007-06-16
      [3] => OUT
      [IN_OUT] => OUT
      [4] => 15:00:00
      [IN_TIME] => 15:00:00
      [5] => 16:00:00
      [OUT_TIME] => 16:00:00
      [6] => 00:20:00
      [TOTAL_TIME] => 00:20:00
      [7] => 03:34:02
      [FLEX_TIME] => 03:34:02
      [8] => 03:52:24
      [FLEX_BALANCE] => 03:52:24
      [9] => 00:00:00
      [NORM] => 00:00:00
      [10] => 02:20:00
      [DIFF] => 02:20:00
      [11] => 0
      [OVERTIME_FLAG] => 0
      [12] => 00:00:00
      [OVERTIME_50] => 00:00:00
      [13] => 00:00:00
      [OVERTIME_100] => 00:00:00
      [14] => 0
      [UPDATE_BY_ADMIN] => 0
      [15] => 07:26:26
      [FLEX_TOTAL] => 07:26:26
      )



      Array
      (
      [0] => 6
      [ID] => 6
      [1] => 2
      [EMPLOYEE_ID] => 2
      [2] => 2007-06-16
      [UPDATE_DATE] => 2007-06-16
      [3] => OUT
      [IN_OUT] => OUT
      [4] => 15:00:00
      [IN_TIME] => 15:00:00
      [5] => 16:00:00
      [OUT_TIME] => 16:00:00
      [6] => 00:00:00
      [TOTAL_TIME] => 00:00:00
      [7] => 03:34:02
      [FLEX_TIME] => 03:34:02
      [8] => 03:52:24
      [FLEX_BALANCE] => 03:52:24
      [9] => 00:00:00
      [NORM] => 00:00:00
      [10] => 02:00:00
      [DIFF] => 02:00:00
      [11] => 0
      [OVERTIME_FLAG] => 0
      [12] => 00:00:00
      [OVERTIME_50] => 00:00:00
      [13] => 00:00:00
      [OVERTIME_100] => 00:00:00
      [14] => 0
      [UPDATE_BY_ADMIN] => 0
      [15] => 07:26:26
      [FLEX_TOTAL] => 07:26:26
      )

      update daily_timerecord set TOTAL_TIME=SUBTIME('00:00:00',TIMEDIFF
      ('12:20:00','12:00:00')),DIFF=SUBTIME(DIFF,TIMEDIFF
      ('12:20:00','12:00:00')) where EMPLOYEE_ID=2 and UPDATE_DATE='2007-
      06-16'

      You can see here IN_TIME is taking old once though i have changed it
      in first query!! why The update query is not runnig properly one by
      one..


      Please let me know I need it as soon as possible.

      Bhavna
    • maq005
      Hey put all the queries into transaction and try..... I mean start the transaction before and End the transaction after the last query..... Look into the
      Message 2 of 5 , Jun 19 3:00 AM
        Hey put all the queries into transaction and try..... I mean start the
        transaction before and End the transaction after the last query.....

        Look into the manual for that...... and lemme tell you, nested
        transations are not supported in poatgres but donno abt mysql check
        the manual.....




        --- In bang-phpug@yahoogroups.com, "bhavna_coolinus"
        <bhavna_coolinus@...> wrote:
        >
        > Hi,
        >
        > I am calling some function consicutively each func having update
        > query...
        >
        > but some update query not running in php, if i run same query un
        > phpMyadmin it runs properly...
        > I can't update table using one update query bcoz i have to fech
        > table agin and again after finishing one update..
        >
        > its like i am calling three functions like
        >
        > $today = getPresent($dblink,$id,$date);
        > echo "<pre>";print_r
        > ($today);echo "</pre>";
        > if(count($today) > 0)
        > {
        > sleep(1);
        >
        > changeInOutTime($dblink,$id,$inTime,$outTime,$date,$today);
        > sleep(1);
        >
        > $afterFirst= "";
        > $afterFirst
        > = getPresent($dblink,$id,$date);
        >
        > echo "<pre>";print_r($afterFirst);echo "</pre>";
        >
        > deductCoffeeTime
        > ($dblink,$id,$inTime,$outTime,$date,$afterFirst);
        > sleep(1);
        >
        > $afterSecond= "";
        > $afterSecond
        > = getPresent($dblink,$id,$date);
        >
        > echo "<pre>";print_r($afterSecond);echo "</pre>";
        >
        > deductLunchTime
        > ($dblink,$id,$inTime,$outTime,$date,$afterSecond);
        > }
        >
        > and its output comes like
        >
        > Array
        > (
        > [0] => 6
        > [ID] => 6
        > [1] => 2
        > [EMPLOYEE_ID] => 2
        > [2] => 2007-06-16
        > [UPDATE_DATE] => 2007-06-16
        > [3] => OUT
        > [IN_OUT] => OUT
        > [4] => 15:00:00
        > [IN_TIME] => 15:00:00
        > [5] => 16:00:00
        > [OUT_TIME] => 16:00:00
        > [6] => 00:20:00
        > [TOTAL_TIME] => 00:20:00
        > [7] => 03:34:02
        > [FLEX_TIME] => 03:34:02
        > [8] => 03:52:24
        > [FLEX_BALANCE] => 03:52:24
        > [9] => 00:00:00
        > [NORM] => 00:00:00
        > [10] => 02:20:00
        > [DIFF] => 02:20:00
        > [11] => 0
        > [OVERTIME_FLAG] => 0
        > [12] => 00:00:00
        > [OVERTIME_50] => 00:00:00
        > [13] => 00:00:00
        > [OVERTIME_100] => 00:00:00
        > [14] => 0
        > [UPDATE_BY_ADMIN] => 0
        > [15] => 07:26:26
        > [FLEX_TOTAL] => 07:26:26
        > )
        >
        > update daily_timerecord set DIFF=SUBTIME('00:20:00',SUBTIME
        > ('16:00:00','12:00:00'),IN_TIME='12:00:00',OUT_TIME='16:00:00',TOTAL_
        > TIME=SUBTIME('16:00:00','12:00:00') where EMPLOYEE_ID=2 and
        > UPDATE_DATE='2007-06-16'
        >
        > Array
        > (
        > [0] => 6
        > [ID] => 6
        > [1] => 2
        > [EMPLOYEE_ID] => 2
        > [2] => 2007-06-16
        > [UPDATE_DATE] => 2007-06-16
        > [3] => OUT
        > [IN_OUT] => OUT
        > [4] => 15:00:00
        > [IN_TIME] => 15:00:00
        > [5] => 16:00:00
        > [OUT_TIME] => 16:00:00
        > [6] => 00:20:00
        > [TOTAL_TIME] => 00:20:00
        > [7] => 03:34:02
        > [FLEX_TIME] => 03:34:02
        > [8] => 03:52:24
        > [FLEX_BALANCE] => 03:52:24
        > [9] => 00:00:00
        > [NORM] => 00:00:00
        > [10] => 02:20:00
        > [DIFF] => 02:20:00
        > [11] => 0
        > [OVERTIME_FLAG] => 0
        > [12] => 00:00:00
        > [OVERTIME_50] => 00:00:00
        > [13] => 00:00:00
        > [OVERTIME_100] => 00:00:00
        > [14] => 0
        > [UPDATE_BY_ADMIN] => 0
        > [15] => 07:26:26
        > [FLEX_TOTAL] => 07:26:26
        > )
        >
        >
        >
        > Array
        > (
        > [0] => 6
        > [ID] => 6
        > [1] => 2
        > [EMPLOYEE_ID] => 2
        > [2] => 2007-06-16
        > [UPDATE_DATE] => 2007-06-16
        > [3] => OUT
        > [IN_OUT] => OUT
        > [4] => 15:00:00
        > [IN_TIME] => 15:00:00
        > [5] => 16:00:00
        > [OUT_TIME] => 16:00:00
        > [6] => 00:00:00
        > [TOTAL_TIME] => 00:00:00
        > [7] => 03:34:02
        > [FLEX_TIME] => 03:34:02
        > [8] => 03:52:24
        > [FLEX_BALANCE] => 03:52:24
        > [9] => 00:00:00
        > [NORM] => 00:00:00
        > [10] => 02:00:00
        > [DIFF] => 02:00:00
        > [11] => 0
        > [OVERTIME_FLAG] => 0
        > [12] => 00:00:00
        > [OVERTIME_50] => 00:00:00
        > [13] => 00:00:00
        > [OVERTIME_100] => 00:00:00
        > [14] => 0
        > [UPDATE_BY_ADMIN] => 0
        > [15] => 07:26:26
        > [FLEX_TOTAL] => 07:26:26
        > )
        >
        > update daily_timerecord set TOTAL_TIME=SUBTIME('00:00:00',TIMEDIFF
        > ('12:20:00','12:00:00')),DIFF=SUBTIME(DIFF,TIMEDIFF
        > ('12:20:00','12:00:00')) where EMPLOYEE_ID=2 and UPDATE_DATE='2007-
        > 06-16'
        >
        > You can see here IN_TIME is taking old once though i have changed it
        > in first query!! why The update query is not runnig properly one by
        > one..
        >
        >
        > Please let me know I need it as soon as possible.
        >
        > Bhavna
        >
      • Chidu
        ... Hi Bhavna, It seems to be that, ur a have a very small problem in here, with the query, Even, I did face the same knida problem just a month ago, be sure
        Message 3 of 5 , Jun 19 4:17 AM
          >
          > _,_._,___
          >
          Hi Bhavna,

          It seems to be that, ur a have a very small problem in here, with the query,
          Even, I did face the same knida problem just a month ago, be sure that, you
          don't leave spaces in between any mysql functions, while typing up the
          query, phpmyadmin removes any whitespaces in the query and you are able to
          run them without any hasle.

          I suggest u, to just a look back on ur code...

          For Ex.:
          Your query here:

          update daily_timerecord set DIFF=SUBTIME('00:20:00',SUBTIME
          ('16:00:00','12:00:00'),IN_TIME='12:00:00',OUT_TIME='16:00:00',TOTAL_
          TIME=SUBTIME('16:00:00','12:00:00') where EMPLOYEE_ID=2 and
          UPDATE_DATE='2007-06-16'

          and

          update daily_timerecord set TOTAL_TIME=SUBTIME('00:00:00',TIMEDIFF
          ('12:20:00','12:00:00')),DIFF=SUBTIME(DIFF,TIMEDIFF
          ('12:20:00','12:00:00')) where EMPLOYEE_ID=2 and UPDATE_DATE='2007-
          06-16'

          A small and little correction: just remove the spaces in the functions: here
          have a look:

          update daily_timerecord set
          DIFF=SUBTIME('00:20:00',SUBTIME('16:00:00','12:00:00')), IN_TIME='12:00:00',
          OUT_TIME='16:00:00', TOTAL_TIME=SUBTIME('16:00:00','12:00:00') where
          EMPLOYEE_ID=2 and UPDATE_DATE='2007-06-16'

          and second query here:

          update daily_timerecord set TOTAL_TIME=SUBTIME('00:00:00',
          TIMEDIFF('12:20:00','12:00:00')),
          DIFF=SUBTIME(DIFF,TIMEDIFF('12:20:00','12:00:00')) where EMPLOYEE_ID=2 and
          UPDATE_DATE='2007-06-16'

          your only problems seems to be right here:
          your code : TIMEDIFF ('12:20:00','12:00:00')
          my suggestion : TIMEDIFF('12:20:00','12:00:00')


          That's seems to be very silly and basically shouldn't matter at all, since I
          faced the same problem, I just though of sharing with u. As, Iike ur problem
          is related to updation of the tables, for every update check for a value to
          be updated and then run the next query...

          --
          Chidanand. G. B
          +91-98456-51235


          [Non-text portions of this message have been removed]
        • bhavna patel
          Thanks for your suggetion but that s not a problem... see the problem I have notised in every query like update daily_timerecord set DIFF=SUBTIME( 00:20:00
          Message 4 of 5 , Jun 20 1:14 AM
            Thanks for your suggetion but that's not a problem...
            see the problem I have notised in every query like

            update daily_timerecord set DIFF=SUBTIME('00:20:00' ,SUBTIME('16:00:00', '12:00:00')),IN_TIME= '12:00:00' ,OUT_TIME= '16:00:00' ,TOTAL_
            TIME=SUBTIME('16:00:00' ,'12:00:00') where EMPLOYEE_ID= 2 and
            UPDATE_DATE= '2007-06- 16'

            DIFF field is not getting change as i have noticed.
            cant anybudy tell me why its not getting change through php and its getting change through phpmyadmin

            where ever i am updating DIFF its not getting affected!!! I donn know why.
            the rest of field is getting changed...

            i thought its reserved word of PHP or Mysql but its not as i have tried by changing field name also

            Can anyone please help me out!!!

            bhavna.

            ----- Original Message ----
            From: Chidu <chidanandmba@...>
            To: bang-phpug@yahoogroups.com
            Sent: Tuesday, June 19, 2007 1:17:57 PM
            Subject: Re: [bang-phpug] Why more than one update query is not running in php

            >
            > _,_._,___
            >
            Hi Bhavna,

            It seems to be that, ur a have a very small problem in here, with the query,
            Even, I did face the same knida problem just a month ago, be sure that, you
            don't leave spaces in between any mysql functions, while typing up the
            query, phpmyadmin removes any whitespaces in the query and you are able to
            run them without any hasle.

            I suggest u, to just a look back on ur code...

            For Ex.:
            Your query here:

            update daily_timerecord set DIFF=SUBTIME( '00:20:00' ,SUBTIME
            ('16:00:00', '12:00:00' ),IN_TIME= '12:00:00' ,OUT_TIME= '16:00:00' ,TOTAL_
            TIME=SUBTIME( '16:00:00' ,'12:00:00' ) where EMPLOYEE_ID= 2 and
            UPDATE_DATE= '2007-06- 16'

            and

            update daily_timerecord set TOTAL_TIME=SUBTIME( '00:00:00' ,TIMEDIFF
            ('12:20:00', '12:00:00' )),DIFF=SUBTIME( DIFF,TIMEDIFF
            ('12:20:00', '12:00:00' )) where EMPLOYEE_ID= 2 and UPDATE_DATE= '2007-
            06-16'

            A small and little correction: just remove the spaces in the functions: here
            have a look:

            update daily_timerecord set
            DIFF=SUBTIME( '00:20:00' ,SUBTIME( '16:00:00' ,'12:00:00' )), IN_TIME='12: 00:00',
            OUT_TIME='16: 00:00', TOTAL_TIME=SUBTIME( '16:00:00' ,'12:00:00' ) where
            EMPLOYEE_ID= 2 and UPDATE_DATE= '2007-06- 16'

            and second query here:

            update daily_timerecord set TOTAL_TIME=SUBTIME( '00:00:00' ,
            TIMEDIFF('12: 20:00','12: 00:00')),
            DIFF=SUBTIME( DIFF,TIMEDIFF( '12:20:00' ,'12:00:00' )) where EMPLOYEE_ID= 2 and
            UPDATE_DATE= '2007-06- 16'

            your only problems seems to be right here:
            your code : TIMEDIFF ('12:20:00', '12:00:00' )
            my suggestion : TIMEDIFF('12: 20:00','12: 00:00')

            That's seems to be very silly and basically shouldn't matter at all, since I
            faced the same problem, I just though of sharing with u. As, Iike ur problem
            is related to updation of the tables, for every update check for a value to
            be updated and then run the next query...

            --
            Chidanand. G. B
            +91-98456-51235

            [Non-text portions of this message have been removed]






            ____________________________________________________________________________________
            Never miss an email again!
            Yahoo! Toolbar alerts you the instant new Mail arrives.
            http://tools.search.yahoo.com/toolbar/features/mail/

            [Non-text portions of this message have been removed]
          • Ved Prakash
            Hi Bhavna, 1. Check error.log if there is any error message thats getting generated, after you run your application or 2. wherever you are executing query, you
            Message 5 of 5 , Jun 20 5:34 AM
              Hi Bhavna,

              1. Check error.log if there is any error message thats getting generated,
              after you run your application
              or
              2. wherever you are executing query, you should do this

              $res = mysql_query($updatequery);
              if(!$res) {
              echo mysql_error();
              echo $php_errormsg;
              }

              mysql_query would return false if the query fails, and mysql_error would be
              set. $php_errormsg would return the last php error.

              Regards,

              Ved

              On 6/20/07, bhavna patel <bhavna_coolinus@...> wrote:
              >
              > Thanks for your suggetion but that's not a problem...
              > see the problem I have notised in every query like
              >
              > update daily_timerecord set DIFF=SUBTIME('00:20:00' ,SUBTIME('16:00:00',
              > '12:00:00')),IN_TIME= '12:00:00' ,OUT_TIME= '16:00:00' ,TOTAL_
              > TIME=SUBTIME('16:00:00' ,'12:00:00') where EMPLOYEE_ID= 2 and
              > UPDATE_DATE= '2007-06- 16'
              >
              > DIFF field is not getting change as i have noticed.
              > cant anybudy tell me why its not getting change through php and its
              > getting change through phpmyadmin
              >
              > where ever i am updating DIFF its not getting affected!!! I donn know why.
              > the rest of field is getting changed...
              >
              > i thought its reserved word of PHP or Mysql but its not as i have tried by
              > changing field name also
              >
              > Can anyone please help me out!!!
              >
              > bhavna.
              >
              >
              > ----- Original Message ----
              > From: Chidu <chidanandmba@... <chidanandmba%40gmail.com>>
              > To: bang-phpug@yahoogroups.com <bang-phpug%40yahoogroups.com>
              > Sent: Tuesday, June 19, 2007 1:17:57 PM
              > Subject: Re: [bang-phpug] Why more than one update query is not running in
              > php
              >
              > >
              > > _,_._,___
              > >
              > Hi Bhavna,
              >
              > It seems to be that, ur a have a very small problem in here, with the
              > query,
              > Even, I did face the same knida problem just a month ago, be sure that,
              > you
              > don't leave spaces in between any mysql functions, while typing up the
              > query, phpmyadmin removes any whitespaces in the query and you are able to
              > run them without any hasle.
              >
              > I suggest u, to just a look back on ur code...
              >
              > For Ex.:
              > Your query here:
              >
              > update daily_timerecord set DIFF=SUBTIME( '00:20:00' ,SUBTIME
              > ('16:00:00', '12:00:00' ),IN_TIME= '12:00:00' ,OUT_TIME= '16:00:00'
              > ,TOTAL_
              > TIME=SUBTIME( '16:00:00' ,'12:00:00' ) where EMPLOYEE_ID= 2 and
              > UPDATE_DATE= '2007-06- 16'
              >
              > and
              >
              > update daily_timerecord set TOTAL_TIME=SUBTIME( '00:00:00' ,TIMEDIFF
              > ('12:20:00', '12:00:00' )),DIFF=SUBTIME( DIFF,TIMEDIFF
              > ('12:20:00', '12:00:00' )) where EMPLOYEE_ID= 2 and UPDATE_DATE= '2007-
              > 06-16'
              >
              > A small and little correction: just remove the spaces in the functions:
              > here
              > have a look:
              >
              > update daily_timerecord set
              > DIFF=SUBTIME( '00:20:00' ,SUBTIME( '16:00:00' ,'12:00:00' )), IN_TIME='12:
              > 00:00',
              > OUT_TIME='16: 00:00', TOTAL_TIME=SUBTIME( '16:00:00' ,'12:00:00' ) where
              > EMPLOYEE_ID= 2 and UPDATE_DATE= '2007-06- 16'
              >
              > and second query here:
              >
              > update daily_timerecord set TOTAL_TIME=SUBTIME( '00:00:00' ,
              > TIMEDIFF('12: 20:00','12: 00:00')),
              > DIFF=SUBTIME( DIFF,TIMEDIFF( '12:20:00' ,'12:00:00' )) where EMPLOYEE_ID=
              > 2 and
              > UPDATE_DATE= '2007-06- 16'
              >
              > your only problems seems to be right here:
              > your code : TIMEDIFF ('12:20:00', '12:00:00' )
              > my suggestion : TIMEDIFF('12: 20:00','12: 00:00')
              >
              > That's seems to be very silly and basically shouldn't matter at all, since
              > I
              > faced the same problem, I just though of sharing with u. As, Iike ur
              > problem
              > is related to updation of the tables, for every update check for a value
              > to
              > be updated and then run the next query...
              >
              > --
              > Chidanand. G. B
              > +91-98456-51235
              >
              > [Non-text portions of this message have been removed]
              >
              > __________________________________________________________
              > Never miss an email again!
              > Yahoo! Toolbar alerts you the instant new Mail arrives.
              > http://tools.search.yahoo.com/toolbar/features/mail/
              >
              > [Non-text portions of this message have been removed]
              >
              >
              >


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.