Arie Posted December 15, 2009 Share Posted December 15, 2009 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 More sharing options...
taquitosensei Posted December 15, 2009 Share Posted December 15, 2009 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 More sharing options...
Arie Posted December 15, 2009 Author Share Posted December 15, 2009 When i echo $actualresult then i get "Resource id #5" and when i echo $actualresult1 the i get "array". So there has to be something wrong with my query then? Link to comment https://forums.phpfreaks.com/topic/185225-update-to-database/#findComment-977797 Share on other sites More sharing options...
Arie Posted December 16, 2009 Author Share Posted December 16, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.