0

I have a line of code in which it overrides the result in database. To make it clearer, In database the REMARKS is "Stopped" but in UI"website" it shows running.

This is the code which does the override

'remarks'   => ($rowmaxtec['speed']  > 0 
 and 
 $rowmaxtec['ENGINE'] == 'ON') ? 'Running' : $rowmaxtec['REMARKS'],

Now what I want is not to override it but to update the REMARKS itself. I have this code which did not do well everything I run it. The site just stops responding, I don't know why, Can anyone help me?

Here's the code I tried to create

'remarks'   => ($rowmaxtec['speed']  > 0 and $rowmaxtec['ENGINE'] == 'ON') ? 
                      "UPDATE TBLGPS
                      SET REMARKS = 'Running'
                      WHERE SPEED > '0' AND $rowmaxtec['ENGINE'] == 'ON'" : $rowmaxtec['REMARKS'],

I tried to use it but it doesn't run at all. Kindly advice or help. Advance thanks.

Dodgeball
  • 125
  • 2
  • 14
  • Always when developing code, turn on `error_reporting` and display errors on screen with `error_reporting(E_ALL); ini_set('display_errors', 1);` at the top of your script. You have a fatal error here, in the array values inserted in the double-quoted string: http://stackoverflow.com/a/13935532/541091 – Michael Berkowski Aug 26 '14 at 02:23
  • Did you expect the SQL to run in that context and/or return a value? Declare it in a function, if so. – mario Aug 26 '14 at 02:26
  • It isn't clear what database access API you're going to execute this UPDATE with or the sources of these `$rowmaxtec` values, but it might be a SQL injection vulnerability. If your API supports it, consider using prepared statements with bound parameters (which also avoids the variable interpolation & quoting problem you have now).' – Michael Berkowski Aug 26 '14 at 02:26
  • Ok Thanks for all the tips. In addition, what I want it to update the remarks. In the first code which is `'remarks' => ($rowmaxtec['speed'] > 0 and $rowmaxtec['ENGINE'] == 'ON') ? 'Running' : $rowmaxtec['REMARKS'],` instead of just displaying Running I want to update the remarks to Running. Thanks. Hope this addition helps. – Dodgeball Aug 26 '14 at 02:30

0 Answers0