Jump to content

While Function help


acctman

Recommended Posts

I added a while function to process all rows for m_addtn field in the rate_mem table but, nothing is happening. I'm not getting any errors or anything.

 


$res = mysql_query("SELECT m_addtn FROM rate_mem");

//$res = mysql_query("SELECT m_addtn FROM rate_mem WHERE m_id = '39'");
//$results = mysql_fetch_array($res,MYSQL_BOTH);

while($results = mysql_fetch_array($res,MYSQL_BOTH)) {

$decode = unserialize(base64_decode($results['m_addtn']));

$m_orientation = 	$decode['3'];
$m_status = 	$decode['6'];
$m_turn_on = 	$decode['4'];
$m_turn_off = 	$decode['1'];

mysql_query ("UPDATE rate_members SET
             m_orientation = '$m_orientation',
             m_status = '$m_status',
             m_turn_on = '$m_turn_on',
             m_turn_off = '$m_turn_off'
             ");         
//           WHERE m_id = '39'");
}
?>

Link to comment
https://forums.phpfreaks.com/topic/122317-while-function-help/
Share on other sites

Put an "or die" clause on the queries:

<?php
$q = "SELECT m_addtn FROM rate_mem";
$res = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
?>

and

<?php
$q = "UPDATE rate_members SET
             m_orientation = '$m_orientation',
             m_status = '$m_status',
             m_turn_on = '$m_turn_on',
             m_turn_off = '$m_turn_off'
             ";
mysql_query ($q) or die("Problem with the query: $q<br>" . mysql_error());
?>

and see if you get any errors.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/122317-while-function-help/#findComment-631609
Share on other sites

Put an "or die" clause on the queries:

<?php
$q = "SELECT m_addtn FROM rate_mem";
$res = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
?>

and

<?php
$q = "UPDATE rate_members SET
             m_orientation = '$m_orientation',
             m_status = '$m_status',
             m_turn_on = '$m_turn_on',
             m_turn_off = '$m_turn_off'
             ";
mysql_query ($q) or die("Problem with the query: $q<br>" . mysql_error());
?>

and see if you get any errors.

 

Ken

 

ok its process now, but its not each row by itself. It should grab row 1 decode m_addtn then update, then go to row2 and do the same.

Link to comment
https://forums.phpfreaks.com/topic/122317-while-function-help/#findComment-631626
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.