NiallAA Posted June 25, 2013 Share Posted June 25, 2013 The following piece of code updated rows of data when my database was on MySQL 4.0 Now on MySQL 5.0, it does not work. Can anyone offer some help as to why? foreach($_POST['mid'] as $key=>$val) { $percent = $_POST['percent']; $detail = $_POST['detail']; $qty = $_POST['qty']; $rate = $_POST['rate']; mysql_query("UPDATE val_mworks SET mworks_percent = '$percent[$key]', mworks_detail = '$detail[$key]', mworks_qty = '$qty[$key]', mworks_rate = '$rate[$key]' WHERE mworks_id = '$val' ") or die(mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/279553-phpmysql-40-to-mysql-50-foreach-problems/ Share on other sites More sharing options...
dalecosp Posted June 25, 2013 Share Posted June 25, 2013 I'm afraid I can't help based on that alone. For example, what does "It does not work" mean? Do you see a blank page in the browser? Do you receive an error message? Do smoke pour out of the server and choke the SysOp? And, ouch, die() as your only error handler? I guess that depends on some other factors ... if it's in house or development only, that's a quick and dirty way to handle the failure, I guess. To help you with debugging, how about something more like? foreach($_POST['mid'] as $key=>$val) { $percent = $_POST['percent']; $detail = $_POST['detail']; $qty = $_POST['qty']; $rate = $_POST['rate']; $sql = "UPDATE val_mworks SET mworks_percent = '$percent[$key]', mworks_detail = '$detail[$key]', mworks_qty = '$qty[$key]', mworks_rate = '$rate[$key]' WHERE mworks_id = '$val' "; $result = mysql_query($sql); if (!$result) { echo "MySQL Query Failed! SQL was : $sql MySQL said : ".mysql_error(); die(); } }And if that doesn't get you any answers, I'd check logs and possibly open a ticket with your host? (Assuming you have a hosting service, of course). Quote Link to comment https://forums.phpfreaks.com/topic/279553-phpmysql-40-to-mysql-50-foreach-problems/#findComment-1437804 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.