bharanikumarphp Posted July 10, 2008 Share Posted July 10, 2008 dears am having more then 20000 records, in each record i want to add the small word like testing, Below is the code, due to some reason some record not updating, this stop the entire update process Now i want overide this problem, i want to update the record, if any intrept also occur, the proess will never stop, also thing one thing, we have to show the record id, which are not updated 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 { } } } Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted July 10, 2008 Share Posted July 10, 2008 Ok, first off, why are you adding a backslash to something that you grabbed from the database? I ask because it should have already been escaped. And if it made it in the database fine to begin with, then you surely don't need to grab it and then re-addslashes. You'd only need to addslashes if any completely new data is being inserted(and thus, you dont know if you'd been to addslashes). secondly, indent you code. It makes it TONS easier to see whats going on when you have it like this: <?php 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."'"); } } } ?> thirdly, what does your function "break_up" do? and lastly, what is the error you're seeing? a message or just a blank screen? Quote Link to comment Share on other sites More sharing options...
bharanikumarphp Posted July 10, 2008 Author Share Posted July 10, 2008 This is my break up function <?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; } ?> u want to see my content.. this is the sample.. <h1>Header One</h1> <p>Lorem ipsum <em>emphasised text</em> dolor sit amet, <strong>strong text</strong> consectetur adipisicing elit, <abbr title="">abbreviated text</abbr> sed do eiusmod tempor <acronym title="">acronym text</acronym> incididunt ut labore et dolore magna aliqua. Ut <q>quoted text</q> enim ad minim veniam, quis nostrud exercitation <a href="/">link text</a> ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute <del>deleted text</del> <ins>inserted text</ins> irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat <code>code text</code> cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <blockquote> <p>Blockquote. Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia</p> </blockquote> <p><cite><a href="/">Cite author with link text</a></cite>, 2008</p> <h2>Header 2</h2> <p>Extended paragraph. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <ol> <li>Ordered list</li> <li>Item 2 Consectetur adipisicing elit</li> <li>Item 3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</li> <li>Item 4</li> <li>Item 5</li> </ol> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <h3>Header 3</h3> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <ul> <li>Unordered list</li> <li>Consectetur adipisicing elit</li> <li>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</li> <li>Item</li> <li>Item</li> <li>Item</li> </ul> <p>Lorem ipsum dolor sit amet,consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <pre><code>pre and code pair{ display:block; line-height:1.833em; border-top:0.083em solid #200; }</code></pre> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> <h4>Header 4</h4> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <dl> <dt>Definition list</dt> <dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd> <dt>Lorem ipsum dolor sit amet</dt> <dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd> <dt>Lorem ipsum dolor sit amet</dt> <dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd> <dt>Lorem ipsum dolor sit amet</dt> <dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</dd> </dl> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p> <table summary="Table summary"> <caption>Table Caption</caption> <thead> <tr> <th>Header</th><th>Header</th><th>Header</th> <tr> </thead> <tbody> <tr> <td>Content</td><td>1</td><td>a</td> </tr> <tr> <td>Content</td><td>2</td><td>b</td> </tr> <tr> <td>Content</td><td>3</td><td>c</td> </tr> <tr> <td>Content</td><td>4</td><td>d</td> </tr> <tr> <td>Content</td><td>5</td><td>e</td> </tr> <tr> <td>Content</td><td>6</td><td>f</td> </tr> </tbody> </table> <address>Author text</address> in the above sample content, i want to add the <--break--> for that only that break up function is use..... so in this i want to add the this <--break--> to all my 20000 content, so that , update function is required, so in that 20000 content , some record not support the breakup function , so the update process is stopping, now my thing is , what ever intrept occuring, never stops the update process, ow if any record not update, we have to show the record id no also sh Thanks for ur intrest Quote Link to comment 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.