A more practical PHP programming skills

Source: Internet
Author: User
Tags comparison ini integer join mysql mysql insert php programming
1 in an SQL statement, you can add a restriction condition: Left (TEXT20) only the first 20 words of the text, and 2 can be used as paging using limit FromRecord Recordnum For example, limit 030 means to traverse 30 records from the first record;

1 in the SQL statement you can add a restriction condition: Left (TEXT20) only the first 20 words of the text;
2 can be used as pagination using limit FromRecord recordnum For example, limit 030 indicates that 30 records are traversed from the first record;
A 32-table connection can be: Table1 join table2 using X (x is a common field for two tables) or Table1 join table2 on table1.x = table2.x
4 PHP Access querystring can be used $page = $_get[' page '];
Or
$page = $_request[' page '];
Which request can obtain postgetquerystring and other characters;
Before that, I saw a more stupid way:
Parse_str ($_server[' query_string '] $output); First, save the query string into an array $output
$page = $output [' page '];
5 The comparison of date functions in PHP is actually a string comparison;
6 Date type data in MySQL can be: 2000-02-032002.02.032002.2.302.02.0302.2.3, which means there must be a month and a day, and must be '-' or '. ' Apart.
7 data () to get the time zone problem, I found that the time is less than 8 hours because the php.ini inside the default configuration is GTM U.S. time zone;
WORKAROUND: You can modify the php.ini:
[Date]
; Defines the default timezone used by the date functions
Date.timezone = "Asia/shanghai"
Alternatively, use the date () function plus date_default_timezone_set ("PRC");
81 Period of Time debugging in the body always said I was missing ""), the cost of a half-day is intval ($_post[' Consumetype '), the field in the database is varchar (50), in the Zengsong table I do not use the Intval function, Because its ID is 1,2 ... integers and char can convert to each other, but in the other two tables it's a5asp07-01, but how does it convert to int?
Let's look at the declaration of the Intval function:
The Intval function is used to get the integer value of the variable: int intval (mixed var [int ba SE])
Returns the integer value of the variable var by using a specific binary conversion (the default is decimal).
var can be any scalar type. Intval () cannot be used for array or OB Ject.
9 Another inexplicable problem with user Name 1 login can be, change a ' Bo ' Landing, the system is in place error: Said I run time error: lack of "", Nnd. Check that the variable type in the SQL statement is inconsistent with the database,
In PHP when you convert from floating-point numbers to integers, the digits are rounded up (drop decimal places).
11 in the MySQL INSERT statement, if the self-added field is to be replaced with (NULL).
PHP in Chinese garbled??? Problem solving:
Adding mysql_query ("Set names ' gb2312") after mysql_connect;
Or the full use of UTF8 code, you do not have to add the above statement.
There is also a function iconv ("GBK" "UTF8" "string"), which enables the conversion of various character encodings.



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.