Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8046405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:46:34+00:00 2026-06-05T05:46:34+00:00

<?php $tr_no = mysql_num_rows($query); $ii = 0; //iterator; while($news = mysql_fetch_array($query)) //replacing special characters

  • 0
<?php
    $tr_no = mysql_num_rows($query);
    $ii = 0; //iterator;
    while($news = mysql_fetch_array($query))

        //replacing special characters
        $replacename = eregi_replace(" ",  "-", $news['3']);
        $pattern = array();
        $pattern[0] = '-';
        $pattern[1] = "'";
        $replace = array();
        $replace[0] = '&#45;';
        $replace[1] = '&#39;';
        $news['2'] = preg_replace($pattern,$replace,$news['2']);
        $news['1'] = preg_replace($pattern,$replace,$news['1']);
        echo "<div style='width: 600px;' align='center'>";
        if($ii % 2 == 0){
            echo "<div style='width: 290px; height: 350px; float: left; padding:5px;'><h3 style='color:#ff0000; font-size: 14px;'>".$news['2']."</h3><p style='font-size:12px;'>".$news['1']."...</p><p><a href=\"".$href ."/". $replacename ."/item/".$news['0']."\">read more...</a></p></div>";
        }
        if($ii % 2 == 1){
            echo "<div style='width: 290px; height: 350px; float: left; padding:5px;'><h3 style='color:#ff0000; font-size: 14px;'>".$news['2']."</h3><p style='font-size:12px;'>".$news['1']."...</p><p><a href=\"".$href ."/". $replacename ."/item/".$news['0']."\">read more...</a></p></div>";
        }
        echo "</div>";
        $ii++;
    }
?>

The code output strings from the database while looping, but some characters appear invalid in an html format, see details: http://ipaidabribenaija.com/newsletter2.php
I have also used str_replace() in place of preg_replace(), but the functions are not effective in this situation.

Please how can i achieve this task?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:46:35+00:00Added an answer on June 5, 2026 at 5:46 am

    try

    $str = mb_decode_numericentity($str, array(0, 0x10FFFF, 0, 0xFFFFFF), 'UTF-8');
    

    ie

    $news[2] =  mb_decode_numericentity($news[2], array(0, 0x10FFFF, 0, 0xFFFFFF), 'UTF-8');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

'view_act.php' file <?php $query = mysql_query('select * from activities'); $check=mysql_num_rows($query); if($check==0) { echo No
How can I display data in two columns? <?php $query = SELECT * FROM
I am receiving a pagination error in my php script. The query works fine
It's been a little while with PHP, so please excuse my ignorance. I have
I have a php page query mysql database, it will return about 20000 rows.
while ($row = mysql_fetch_row($result)) { echo <tr>; echo (<p><td>$row[2]</td><td>$row[0]</td><td>$row[1]</td><td><i>$row[3]</i></td><td><a href=\delete.php?time=$row[2]&user=$row[0]&pass=$row[1]\><center>[x]</center></a></td></p>); echo </tr>; $x++; }
I have a PHP page displaying the results of a MySQL query. It adds
Namely the href snippet of echo <tr><td align=center> <a href=\edit.php?id=$id&name=$name&email=$email&password=$password\>$id</a></td> <td>$name</td><td>$email</td><td>$password</td></tr>; I don't know
<?php foreach ($data['ACTION_DATA']['messages'] as $msg) { ?> <form> <table> <tr><td>Name:</td><td id=name><?php echo $msg['name']; ?>
$.ajax({ type: POST, url: add_secondary_interest.php, data: interest=ok, cache: false, success: function(html){ $('#interest_table tr:last').after(html); }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.