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 ~