Jump to content

update problem


Recommended Posts

hi dears

 

am facing update problem,

 

the given below code perform, like add the <break--> into contents and update it,

 

now am facing the problem is,

 

when the query is updating, on that time if any one row through error thenprovess is stopped,

 

so i want like this manner,

 

that is i dont want to stop the update process even any record or row through error,

 

and also one more thing is, if the row  or record not updated,

then , that row number must be display... this is my key motive

 

 

<?php
//set_time_limit(0);

mysql_connect("localhost","root","");
mysql_select_db("ameex01") or die("could not select the database");
$sql = "select * from node_revisions where nid=11973";

$rs = mysql_query($sql);
if(mysql_num_rows($rs)>0)
{ 
while($obj=mysql_fetch_object($rs))
{
$body_chunksplit = $obj->body;
$nid=$obj->nid;
$body_chunksplit=str_replace("'", "\'", $body_chunksplit);
// $lrn = strlen($body_chunksplit);
//$length=$lrn*2;

if(strlen($body_chunksplit) >= 4500)
{

$body_content=break_up($body_chunksplit,'<--pagebreak-->', 4500);

//$body_content=substr(chunk_split($body_chunksplit, 4500, "<--pagebreak-->"), 0, $length);
//echo $body_content;
//drupal_set_message(wordcount($body_content));
//$update_query="UPDATE node_revisions SET body='$body_content' where nid='$nid'";

}
else
{
$body_content=$body_chunksplit;
}
if(isset($body_content))
{
$affect=mysql_query("UPDATE node_revisions SET body='$body_content' where nid='$nid'")  or die("could not$nid");
//$affect=mysql_query($update_query)or die("could not at '".$nid."'");
}
else
{

}
}


}

?>


<?php
function break_up( $text, $insert, $chunk = 125 ) {

$counter = 0;

for ( $i = 0; $i < strlen( $text ); $i++ ) {

	# Ignore non-space whitespace characters
	if (  preg_match('/[\t\n\r\f\v]/', $text{$i} )  )
		continue;

	# Check if an HTML tag is opening
	if ( $text{$i} == '<' ) {

		# Let's ignore the rest of the tag
		while ( $text{$i} != '>' )
			$i++;

		continue;

	}

	# Increment character count
	$counter++;

	# Check if chunk size has been reached
	if ( $counter > $chunk ) {

		# Insert string
		$text = substr_replace( $text, $insert, $i, 0 );

		# Increment $i as necessary
		$i += strlen( $insert );

		# Reset counter
		$counter = 0;

	}

}

return $text;

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/113950-update-problem/
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.