What's Wrong With My Php Webpage? - there may be something wrong in my php code.

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

What's Wrong With My Php Webpage? - there may be something wrong in my php code.

takashiro
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;
?>

 

 

 


Reply

turbopowerdmaxsteel
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.

Reply

TavoxPeru
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,


Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : whats, wrong, php, webpage, wrong, php, code,

  1. Activation Code
    (7)
  2. Php Random Selector
    whats the code (2)
    Is there a PHP script that randomly selects a string from a list? example, the list is: 1-Pie
    2-Balls 3-eggs The script would view a random
    word from those 3 every time i run it. Also is there a function that gives a random number between
    0 and a number i select?....
  3. Dynamic Php Image And Better Php Code Question
    (10)
    Im working on a dynamic image, can i put 2 images in same dynamic image, and can i make this code
    shorter? if ( $goal == 31 ) { $xp2 = ('14833'); } elseif ( $goal == 32 ) {
    $xp2 = ('16456'); } elseif ( $goal == 33 ) { $xp2 = ('18247'); }
    elseif ( $goal == 34 ) { $xp2 = ('20224'); } elseif ( $goal == 35 ) {
    $xp2 = ('22406'); } elseif ( $goal == 36 ) { $xp2 = ('24815'); }
    elseif ( $goal == 37 ) { $xp2 = ('27473'); } elseif ( $goal == 38 ) { &#....
  4. Code Snippets Repository
    (0)
    Well as everybody know in these forums people posts a lot of code snippets that could be organized
    in a simple page or whatever, my question is if someone is interested to do it or if exists
    something like that here at astahost. I think it would be very helpful for everybody as well to
    keep things more organized. Best regards,....
  5. How Can I Write PHP Code By This Formmail Html
    (5)
    purpose is i want the information in the web page sent into my email. i just know that i need to use
    php script to operate this action ,but i have no idea about this php code. so anyone can help me
    please... thank you very much. ชื่อ
    ....................... ....... นามสกุล
    ....... ชื่อเล่น
    วันเกิด 1 2 3 4 5 6 7 8 9 10 11
    12 13 14 15 16 ....
  6. [PHP + MySQL] Separating The Results By Pages
    Simple code (0)
    Hi! I will post here a code for separating the results of MySQL in pages. You ask: Why separete?
    I answer: Imagin that you have 1523 results to display. I dont have to say anything. =P Here is it.
    ------------------------------------------------------------------- CODE <?php $conect
    = mysql_connect("host","user","password"); $select_db =
    mysql_select_db("database"); $query = "SELECT * FROM mytable";
    $results = "15"; //Number of results displayed per page. if (!$p....
  7. What's Wrong With This Preg_replace Code?
    (2)
    I have written a JavaScript that prompts auser for 5 table attributes for entry into the posting
    area and it produces this: It is then passed through this preg_replace for display in the
    preview or as a submission in a post: CODE $txt = preg_replace( "#\[table
    bd=(.+?)bgc=(.+?)bdc=(.+?)cp=(.+?)cs=(.+?)\](.+
    ?)\[/table\]#is", "<table
    border=\\1bgcolor=\\2bordercolor=\\3cellpadding=\\4cellspaci
    ng=\\5>&....
  8. Any Tool/software For Php Code Generation ?
    Tool for code generator (3)
    Where find any tool to generate PHP class?....
  9. How To Use Cookie In Your Web Site ?
    this semple code to use and get cookie (1)
    what is the cookie ? the cookis it is some info sent and save in user computer whare i can use the
    cookies? becouse the cookies it like the header you can not send it after any output wes sent so
    you must send the cookies before any output like as ,echo and any other code i well make an E.X.
    to use the cookies you must have 2 file index.php update.php ---------- in the index.php add this
    code CODE <?    // This section must go at the top of the page that will display    //
    the users favorites.  These are the 'default' URLs that the user    // ....
  10. Php Reading And Writing To File
    the code is very esay (4)
    this code to Read from file you can use this code in to make a small data base and it is very to
    use CODE $fp = fopen ("file.txt", "r"); $bytes = 4;
    $buffer = fread($fp, $bytes); fclose ($fp); print
    $buffer; ------------------- to write to same file CODE $fp = fopen
    ("file.txt", "w+"); fwrite ($fp, "Test"); fclose
    ($fp); ---------------- thanks and iwait the commant....
  11. A Php Loginbox On Your Webpage
    Is it possible? (6)
    You know how when you password protect a page/directory, and try to access that page/directory, you
    would be prompted to type in your username and password? Is it possible for me to input some code on
    a page so that the person types his uername and password on the webpage itself like those loginboxes
    which you seein many websites. I know i sound kinda stupid but I was just hoping that it could work.
    I would appreciate all your help! /biggrin.gif' border='0' style='vertical-align:middle'
    alt='biggrin.gif' /> ....
  12. Page Doesn't Load When This Php Code Is Present ?
    (6)
    CODE <?php switch($_GET['page']) {   case "home";  
       include("index.php");   break;   case "gallery";    
     include("gallery.php");   break;     case "links";    
     include("links.php");   break;   case "guestbook";    
     include("../guestbook/");   break;   case "portfolio";    
     include("portfoilio.php");   break;   case "other";    
     include("other.php");   brea....

    1. Looking for whats, wrong, php, webpage, wrong, php, code,

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for whats, wrong, php, webpage, wrong, php, code,
advertisement




What's Wrong With My Php Webpage? - there may be something wrong in my php code.



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE