Jump to content

Occasionally Missing Row Information


jbolduan

Recommended Posts

Hello,

 

I've inherited a web form that has been exhibiting some strange behavior in that it occasionally drops the row information that is updated after a limited insert is done to create the record.  I'm not sure why someone would do the row creation like this but before I go and start changing things around I was hoping someone might have some insight as to why this might fail.  The code is below and should be straight forward.  Thanks!

 

if (empty($err)) //This is used to check that required fields have been entered.
{
mysql_query("insert into membri set data='".time()."',
	username='".$username."',
	password='".md5($password)."',
	apply='".base64_encode(serialize($apply))."',
	vaccines='".base64_encode(serialize($vaccines))."',
	active='0'"); //This query works always and inserts the proper data
$id = mysql_insert_id();
$query = 'update membri set ';
foreach ($data as $key=>$value)
{
if ($key != 'username' && $key != 'password' && $key != 'apply' && $key != 'vaccines' && $key != 'activ')
{
	$query .= $key.'=\''.$value.'\', ';
}
}
$query = preg_replace('/(, )$/', ' ', $query);
$query = .= 'where id='.$id;
mysql_query($query);

Link to comment
https://forums.phpfreaks.com/topic/140195-occasionally-missing-row-information/
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.