Problem with query combined with variable.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
El Jefe
Forum Newbie
Posts: 1
Joined: Wed Dec 16, 2009 7:16 am

Problem with query combined with variable.

Post 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>';         
}     
}
?>
 
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Problem with query combined with variable.

Post 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."'";
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply