Jump to content

Recommended Posts

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());   
	} 

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? :D

 

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).
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.