Jump to content

Update to Database


Arie

Recommended Posts

Hello Forum Members,

 

I have a problem with updating a variable through a sql statement in a record.

I have in this page more sql queries and everything works, i don't get any errors at all, but my update that i post down here doesn't update the value.

 

Im buzy with this problem for a few day's now and still not working :(

I hope someone can help me with this problem.

Thanks in advance!

 

Greetings Arie

 

 else
{
	$actual = "SELECT actualoutput FROM oee
				WHERE id = (SELECT MAX(id) FROM oee)
				";
				$actualresult = mysql_query($actual) or die (mysql_error());
				if ($myrow=mysql_fetch_array($actualresult)) {
      do { 
		$actualresult1[] = $myrow['actualoutput'];     
      }while ($myrow=mysql_fetch_array($actualresult));
   } 	
	}



	{
	$updateactual = "UPDATE rapportage
				SET actualoutput ='".$actualresult."'
				";
				//WHERE idshift = (SELECT MAX(idshift) FROM rapportage)
	$updateresult = mysql_query( $updateactual ); 
        if ( $updateresult === false ) 
        { 
            // query is mislukt, dus netjes de fout afhandelen 
            echo '<p>Er is een fout opgetreden: 
                  <br />Query: ' . $updateactual . ' 
                  <br />Foutmelding: ' . mysql_error() . '</p>'; 
        } 
  }

Link to comment
https://forums.phpfreaks.com/topic/185225-update-to-database/
Share on other sites

this

$updateactual = "UPDATE rapportage
               SET actualoutput ='".$actualresult."'
               ";
               //WHERE idshift = (SELECT MAX(idshift) FROM rapportage)

should probably look more like this

$updateactual = "
UPDATE 
rapportage
SET 
actualoutput ='".$actualresult."'
WHERE 
idshift = (SELECT MAX(idshift) FROM rapportage)";

you ended your line in the middle of your query had half your query commented out. Also try echoing your query out to make sure that it looks the way it's supposed to. 

Link to comment
https://forums.phpfreaks.com/topic/185225-update-to-database/#findComment-977790
Share on other sites

I print the outcome of the first query to the screen with print_r, and i got array([0]=>666[1]=>666)

The 666 is correct because that is the amount.

But still my UPDATE query does not update the 666 in the actualoutput row...

 

I hope that someone can help me.

 

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/185225-update-to-database/#findComment-978505
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.