Jump to content

str_replace in file_get_contents for multiple items


Go to solution Solved by Lukeidiot,

Recommended Posts

I am drawing a blank or either thinking too hard here. 

 

I am trying to replace each item. I have the pastebin_id that matches in mysql database. (Mysql part is all correct, is the replace script that doesnt completely work.)

 

It seems to be only showing one item replaced.

 

pages/1.txt:

<ul id="filters">
<li><a href="/tumblr-themes">Themes</a> /</li>
<li><a href="/one-column-tumblr-themes">One Column</a> /</li>
<li><a href="/two-columns-tumblr-themes">Two Columns</a> /</li>
<li><a href="/three-columns-tumblr-themes">Three Columns</a> /</li>
<li><a href="/four-columns-tumblr-themes">Four Columns</a> /</li>
<li class="last"><a href="/theme-help">Theme Help</a></li>
</ul>
<ul class="clearfix isotope" id="portfolio-items">
<li class="one isotope-item"><a href="http://tit-133.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/uiqhh9x/EyWm90u45/tit-133.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/HCaMRShp" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-132.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/uiqhh9x/oUcm90u1t/tit-132.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/Y8cDqc5h" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-114.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/uiqhh9x/0PMm8s6th/tit-114.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/yTYYHLkJ" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-105.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/Tv4m8767q/tit-105.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/ZY9hzx34" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-101.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/gqym87667/tit-101.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/YdrPvDdF" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-91.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/DvQm6m4uk/tit-91.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/b9MJpiUa" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-90.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/Re5m6m4ud/tit-90.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/a9QC9aJ5" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-83.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/94gm6m4u6/tit-83.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/kjeFYMrq" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-80.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/QSsm6m4u2/tit-80.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/CmKgnenP" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-79.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/cvQm6m4tx/tit-79.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/Nv2g2L51" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-72.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/5JFm6m4sx/tit-72.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/xKCyPBwt" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-67.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/G1cm6m4sr/tit-67.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/DafcTRFD" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-61.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/DS1m6m4sm/tit-61.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/YMBjUFBM" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-58.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/z3rm6m4sf/tit-58.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/KwA482F5" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-57.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/yZ3m6m4sc/tit-57.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/STNvtktU" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-56.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/9Ckm6m4s6/tit-56.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/WKuG3Rr5" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-54.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/4pgm6m4s0/tit-54.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/w5tFXywz" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-53.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/qp1m6m4qp/tit-53.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/DjJ59aUr" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-47.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/FmUm6m4qk/tit-47.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/Fk81rqge" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-46.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/xN1m6m4qg/tit-46.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/2J0Gwuv8" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-37.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/4p4m6m4qd/tit-37.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/n8MqTnci" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-36.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/jF1m6m4qa/tit-36.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/EhhLbEUk" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-34.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/Vn8m6m4q6/tit-34.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/Y4LnHEZH" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-31.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/MbBm6m4q3/tit-31.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/KbUrYjz8" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-30.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/r6Lm6m4oo/tit-30.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/j4jvCeAe" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-28.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/hC6m6m4ok/tit-28.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/drXrpCV2" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-27.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/epOm6m4oe/tit-27.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/J4LfrRra" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-26.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/wOum6m4ob/tit-26.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/KEprw3WX" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-22.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/0ezm6m4o6/tit-22.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/eF3zGm6E" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-21.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/tQDm6m4o1/tit-21.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/PquYJLkq" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-20.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/VBPm6m4nw/tit-20.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/mGfpanes" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-15.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/uTYm6m4lm/tit-15.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/rHMrgKK8" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-13.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/pCYm6m4lh/tit-13.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/2vNJic53" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-9.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/X0rm6m4lf/tit-9.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/26r4gUST" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-7.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/dSzm6m4l9/tit-7.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/ULwYt9ZT" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-5.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/fGxm6m4l6/tit-5.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/yWzxth4W" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-4.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/0yom6m4l2/tit-4.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/agU7Vqca" target="_blank">click here for theme code</a> </span></li>
<li class="one isotope-item"><a href="http://tit-1.tumblr.com" target="_blank"> <img alt="" height="187" 
 
src="http://static.tumblr.com/tpqedpr/0cxm6m4kl/tit-1.png" width="280" /></a> <span class="title"> <a 
 
href="http://pastebin.com/gjd9QQHx" target="_blank">click here for theme code</a> </span></li>
</ul>
<div class="pagination"><span>1 page of 1</span>
<div class="numbers"><a href="#">1</a></div>
</div>

Replace Script:

<?php
 
$columns = 'pages/1.txt';
 
mysql_connect('localhost', 'root', '');
mysql_select_db('themes');
 
 
$html = file_get_contents("$columns");
 
$sql = mysql_query("SELECT * FROM themes WHERE columns = 'one-column-tumblr-themes'");
 
while($row = mysql_fetch_assoc($sql)){
 
$new = str_replace("http://pastebin.com/$row[pastebin_id]", "http://tsil.co/theme?id=$row[name]", $html);
 
}
 
echo $new;
 
?>
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.