Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> What's Wrong With My Php Webpage?, there may be something wrong in my php code.
takashiro
post Jan 5 2008, 10:12 AM
Post #1


Member [ Level 1 ]
Group Icon

Group: [HOSTED]
Posts: 44
Joined: 26-August 07
Member No.: 24,372



This is the first time I use the functions fopen() and preg_replace() . It seems that there's somthing wrong. Where did I write by mistake?

CODE
<?php
include('data/workinfo/0.php');
$viewwork = substr($work[0],0,249);

/* HERE CAN'T WORK WELL! */
$newthread = fopen("http://c8s2007.freetzi.com/bbs/new.php?action=article&digest=0&postdate=0&author=1&fname=0&hits=0&replies=1&pre=6&num=10&length=35&order=1", "rb");
if(!$newthread){
        $newthread = "无法调用信息!";
    }else{
        $ad = "</div></span></ilayer></layer></iframe></noframes></style></noscript></script></applet></xmp></pre></comment></xml></noembed>";
        $ad .= "&lt;script type='text/javascript'";
        $ad .= "src='http://www.freetzi.com/category1/p.js'>";
        $ad .= "</script>";
        $newthread = preg_replace($ad, "", $newthread);
};
/* HERE CAN'T WORK WELL! */

echo <<< EOT
<div class="container">
<div class="side">
    <div class="credit_info"><h2>最近更新</h2><ul>
    <li><img src="daily/2007-11-24-1.jpg" />
    <p>参加“无车日”千人骑车活动</p>
    </li>
    <li><img src="daily/2007-11-24-2.jpg" />
    <p>运动会中,我们留下了美好的记忆,我们不是最好的,但我们可以更好...</p>
    </li>
    </ul></div>
</div>
<div class="content">
    <div id="announcement"><div id="announcementbody">
        <marquee behavior="scroll" direction="left" scrolldelay="170" onMouseOver="this.stop();" onMouseOut="this.start();">
        &lt;script src="http://c8s2007.007ihost.com/bbs/new.php?action=notice&num=5&date=1&length=30"></script>
        </marquee>
    </div></div>
    <div class="box"><h4>Class 8, Senior 2007</h4><table>
        <tr><td width="33%">
        <h2><a href="index.php?page=photo">班级相册</a></h2><p>放置我们留下的每一个瞬间。</p>
        </td>
        <td width="33%">
        <h2><a href="index.php?page=creation">班级作品展</a></h2><p>这里准备放设计的作品,文章等等。</p>
        </td>
        <td width="33%">
        <h2><a href="bbs/">班级论坛</a></h2><p>灌水的好去处。发挥你灌水的本能....</p>
        </td>
        </tr><tr>
        <td>
        <h2><a href="index.php?page=teacher">教师风采</a></h2><p>展示我们最最可爱的老师。</p>
        </td>
        <td>
        <h2><a href="bbs/thread.php?fid=10">留言本</a></h2><p>对网站的任何意见都可以在这里提出来。</p>
        </td>
        <td>
        <h2></h2><p></p>
        </td>
        </tr></table>
    </div>
    <div class="mainbox"><h1>主页内容</h1><table><thead><tr>
        <td width="33%">最新图片</td>
        <td width="33%">最新作品</td>
        <td width="33%">最新论坛帖子</td>
        </tr></thead><tbody><tr>
        <td>&lt;script src="include/pixviewer.js"></script></td>
        <td><p><b>$worklist[0]</b>($author[0])</p> $viewwork ……<br><p><strong><a href="index.php?page=creation&id=0">查看详细</a></strong></p></td>
        <td>&lt;script>$newthread</script></td>
        </tr></tbody></table>
    </div>
</div>
</div>
EOT;
?>


This post has been edited by pyost: Jan 6 2008, 10:35 PM
Go to the top of the page
 
+Quote Post
turbopowerdmaxst...
post Jan 5 2008, 01:41 PM
Post #2


Premium Member
Group Icon

Group: [HOSTED]
Posts: 392
Joined: 16-February 06
From: Kolkata, India
Member No.: 11,322



You are trying to remove some fixed portion of the text read from the remote file, correct? There's no use for a regular expression over there. Besides, the pattern you are specifying as the first parameter for the preg_replace function is not much of a regular expression either. Just use substr_replace function, that would do the job.

P.S. I was unsure if a remote file with query in the URL could be read using fopen but none of the documentation pages depict that.

You should post the code inside the [ code ] [ /code ] tags. Codes are not meant to fetch you Credits. Better make this change yourself. You'll loose a lot more points as penalty, if a moderator changes it.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jan 6 2008, 04:12 AM
Post #3


Super Member
Group Icon

Group: [HOSTED]
Posts: 763
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



Which PHP version do you use and what is the exactly error code/message that you receive if available???

do you try to do the same thing using cUrl??? because i know that it has more or less the same functionality.

Take a look to these pages at the online PHP manual:Best regards,

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Php Reading And Writing To File(4)
  2. How To Use Cookie In Your Web Site ?(1)
  3. Any Tool/software For Php Code Generation ?(3)
  4. What's Wrong With This Preg_replace Code?(2)
  5. [PHP + MySQL] Separating The Results By Pages(0)
  6. How Can I Write PHP Code By This Formmail Html(5)
  7. Code Snippets Repository(0)
  8. Dynamic Php Image And Better Php Code Question(10)
  9. Php Random Selector(2)
  10. Activation Code(7)


 



- Lo-Fi Version Time is now: 11th October 2008 - 02:40 PM