Page 1 of 1

Problem with query combined with variable.

Posted: Wed Dec 16, 2009 7:24 am
by El Jefe
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.

I think it is the first query that is not good at all, but i cant find the problem(im pretty new to all this)

Im buzy with this problem for a few day's now and its still not working, im becoming pretty desperate now.
I hope you understand my problem and that someone can help me with this problem.
Many thanks in advance!

Greetings Arie

Code: Select all

 
<?php
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 ='".$actualresult1."'                  
";                          
$updateresult = mysql_query( $updateactual );         
if ( $updateresult === false )         
{             
// query is mislukt, dus netjes de fout afhandelen, problem solving             
echo '<p>Er is een fout opgetreden:                   
<br />Query: ' . $updateactual . '                   
<br />Foutmelding: ' . mysql_error() . '</p>';         
}     
}
?>
 

Re: Problem with query combined with variable.

Posted: Wed Dec 16, 2009 9:22 am
by AbraCadaver
You've defined $actualresult1 as an array not a single value. So you either need to put this in your loop and use a single value, or construct another loop.

Code: Select all

$updateactual = "UPDATE rapportage SET actualoutput ='".$actualresult1."'";