Convert access to MySQL in PHP

Source: Internet
Author: User
Document directory
  • 1. Access Database reading in PHP:
  • 2. html junk code:
  • 3. PHP code running time
Recently, jky data has been converted from mypower access to dedecms mysql. Some problems are summarized.

1. Access Database reading in PHP:
$ Connstr = "driver = Microsoft Access Driver (*. mdb); DBQ =". realpath ("Pe. mdb ");
$ Connid = odbc_connect ($ connstr, "", "", SQL _cur_use_odbc );
$ Result = odbc_do ($ connid, "select ArticleID, content from article ");

Next, you can get the record through odbc_fetch_row ($ result:

While (odbc_fetch_row ($ result ))
{
$ ArticleID = odbc_result ($ result, "ArticleID ");
$ Cons = str_replace (Array ("'", "<O: P>", "</O: P>"), array ("","", ""), odbc_result ($ result, "content "));
Print "<br>". $ cons;
}

However, there is a problem here: PhP has a limit on the size of the access data field, which can be set in PHP. ini. The default value is:
ODBC. defaultll = 4096
It's only about 4 kb, so I spent a lot of time searching for the update success or some data cannot be inserted into MySQL.

2. html junk code:

This can only be solved through regular expression.

Preg_replace (Array ("/<(//)? Span (? (1)> |/S *? [^>] +?>) /Is ","/<(//)? Font (? (1)> |/S *? [^>] +?>) /Is ","/<P/S +? [^>] +?> /Is ","/<TD/S +? [^>] +?> /Is ","/</? XML: namespace/S +? [^>] +? //>/Is ","/(/R? /N) [/T] *? /R? /N) +/is "), array (" "," "," <p> "," <TD> "," "," // 2 "), $ cons );

Where/<(//)? Span (? (1)> |/S *? [^>] +?>) /Is processing <span> labels
/<(//)? Font (? (1)> |/S *? [^>] +?>) /Is processing font labels
/<P/S +? [^>] +?> /Is processing p tags

3. PHP code running time

PHP code runs at 30 sceond by default, and PHP. INI is set to max_execution_time = 30.
Of course, you can also add this function in the PHP code: set_time_limit (30 );

Dede is a good CMS, and it is not difficult to create a template. Check this CMS ~

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.