Database-PHP writes data to mysql. Is it blank in phpmyadmin and data is printed directly?

Source: Internet
Author: User
{Code ...} I put the project on the sae, and the database is connected. It is okay to capture the content of other webpages and write it into the database. However, when xuegong's webpage is accessed, writing the content to the database is blank in PHPMyAdmin. PHP does not prompt an error, and it is also right to print the content, that is, write...
Function makePage ($ link ){...... // when the URL belongs to xuegong. hubuelse if (strstr ($ link, 'xuegong. hubu') {$ page = curl_init (); curl_setopt ($ page, CURLOPT_URL, $ link); curl_setopt ($ page, CURLOPT_RETURNTRANSFER, 1 ); $ content = curl_exec ($ page); $ content = stristr ($ content, 'class = "title" '); $ content = stristr ($ content, 'class = "bottom" ', true); $ content = str_replace ('class = "title">', '', $ content); $ content = strip_tags ($ content, ''); $ content = stristr ($ content, 'Responsible editor', true); $ content = trim ($ content ); $ content = str_replace ("\ r \ n", "", $ content); $ content = preg_replace ('/(
  ) {2,}/', '', $ content); $ content = str_replace ('href ="', 'href = "http://xuegong.hubu.edu.cn ', $ content ); return $ content ;}// write only the key code $ content = mysql_real_escape_string (makePage ($ notice [1] [$ key]); $ SQL = 'insert ignore into php_notice (title, link, date, content) values ("'. $ value. '","'. $ notice [1] [$ key]. '","'. $ notice [2] [$ key]. '","'. $ content. '");'; mysql_query ($ SQL) or die (mysql_error ());

I put the project on the sae, and the database is connected. It is okay to capture the content of other webpages and write it into the database. However, when xuegong's webpage is accessed, writing the content to the database is blank in PHPMyAdmin.

PHP does not prompt an error, and it is also right to print the content, that is, after writing the data to the database, it becomes a space and the encoding is UTF-8. I don't know what to ask for advice

Reply content:
Function makePage ($ link ){...... // when the URL belongs to xuegong. hubuelse if (strstr ($ link, 'xuegong. hubu') {$ page = curl_init (); curl_setopt ($ page, CURLOPT_URL, $ link); curl_setopt ($ page, CURLOPT_RETURNTRANSFER, 1 ); $ content = curl_exec ($ page); $ content = stristr ($ content, 'class = "title" '); $ content = stristr ($ content, 'class = "bottom" ', true); $ content = str_replace ('class = "title">', '', $ content); $ content = strip_tags ($ content, ''); $ content = stristr ($ content, 'Responsible editor', true); $ content = trim ($ content ); $ content = str_replace ("\ r \ n", "", $ content); $ content = preg_replace ('/(
  ) {2,}/', '', $ content); $ content = str_replace ('href ="', 'href = "http://xuegong.hubu.edu.cn ', $ content ); return $ content ;}// write only the key code $ content = mysql_real_escape_string (makePage ($ notice [1] [$ key]); $ SQL = 'insert ignore into php_notice (title, link, date, content) values ("'. $ value. '","'. $ notice [1] [$ key]. '","'. $ notice [2] [$ key]. '","'. $ content. '");'; mysql_query ($ SQL) or die (mysql_error ());

I put the project on the sae, and the database is connected. It is okay to capture the content of other webpages and write it into the database. However, when xuegong's webpage is accessed, writing the content to the database is blank in PHPMyAdmin.

PHP does not prompt an error, and it is also right to print the content, that is, after writing the data to the database, it becomes a space and the encoding is UTF-8. I don't know what to ask for advice

Run the SQL statement in phpmyadmin?
No one else can tell what the problem is.
In addition, check your field type
Do you know that you have asked Baidu to come here again.

SELECT length (content) Check the content size. It may not be completely displayed!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.