Jump to content


need help replacing info from db


1 reply to this topic

#1 nobodyk

    Newbie

  • Members
  • Pip
  • 0 posts

Posted 05 February 2010 - 07:50 PM

I have this so far:
<?php
$con = mysql_connect("localhost","peter","123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$result = mysql_query("SELECT * FROM phpbb_posts");
if(!$result) die("Query Failed.");

//is this right?
$row['post_text'] = $newrow;
$newrow = preg_replace('/(class="postlink")/','class="postlink" rel="nofollow" target="_blank"',$newrow);
$result = mysql_query("UPDATE phpbb_posts SET post_text=$newrow");
?>
So for each row in phpbb_posts it will get the text, change the link and then it will store it in newrow. From there it will now update the row with the replaced url.

How does this look? I know it's probably wrong.

I want to be able to check all posts in my forum and replace a certain string with a new one. How can this be done?

#2 nobodyk

    Newbie

  • Members
  • Pip
  • 0 posts

Posted 05 February 2010 - 07:54 PM

I forgot to add that post_id is the primary key, it starts from 1 and goes up about 3000, but not all the numbers are being used. For example, there's information on post_id 2 and post_id 4 but post_id 3 doesn't exists. I know this can become a problem.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users