简体   繁体   中英

PHP blank response for query with returns special characters

I have an article in MySQL which has a title column. Now the title column for a specific article id has characters You’ . When I query this article PHP does not return anything at all and the screen is completely blank. "View source" also doesn't show anything.

Here is the code:

static function getArticle($params) 
{
    $id=$params['article_id'];
    $queryv = "SELECT * FROM 'articles WHERE `article_id`='{$id}'";

    $resultv = mysql_query($queryv) or die(json_encode(mysql_error()));
    if (mysql_num_rows($resultv) > 0) 
        {   

            $row = mysql_fetch_assoc($resultv);
            $title=strtoupper($row['article_title']);
            $body=$row['article_body'];
            return(array('article_id'=>$row['article_id'],
                'article_body'=>"<h3 style='width:100%;text-align:center;'>$title</h3>$body",
                'article_title'=>$row['article_title'],
                'article_author'=>$row['article_author'],
                'article_image'=>$row['article_image'],
                'article_share_link'=>$row['article_share_link'],
                'article_author_image'=>$row['article_author_image'],
                ));
        }   
}

I'm using utf8mb4_general_ci as collation in MySQL. phpmyadmin does return the correct result.

I did search online before posting this question but nobody had this problem of getting absolutely no response.

set your php char set to utf-8 by using ini_set( 'default_charset', 'UTF-8' ); then try to SELECT CONVERT("You’",char CHARSET utf8) it may work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM