If the mysql version is too high, this format is not supported? What should I do?

Source: Internet
Author: User
If the mysql version is too high, this format is not supported? If mysql version is too high, it does not support the format of insertinto $ tb (table) set $ var (field value? Parent class: classmysql {& nbsp; public $ host; host & nbsp; public $ db; database & nbsp; public $ user; is this format not supported if mysql version is too high?
If the mysql version is too high, the insert into $ tb (table) set $ var (field = field value) format is not supported?
Parent class:
Class mysql {
Public $ host; // host
Public $ db; // Database
Public $ user; // user name
Public $ pass; // password
Public $ set; // encoding
Function _ construct ($ m, $ a, $ B, $ n, $ c ){
// Function fun ($ m, $ a, $ B, $ n, $ c ){
$ This-> host = $ m;
$ This-> user = $;
$ This-> pass = $ B;
$ This-> db = $ n;
$ This-> set = $ c;
$ This-> conn ();
}
// Link to the database
Function conn (){
Mysql_connect ($ this-> host, $ this-> user, $ this-> pass) or die ($ this-> log_sn ());
Mysql_select_db ($ this-> db) or die ($ this-> log_sn ("database link error! "));
Mysql_query ("setnames. '". $ this-> set ."'");
}
// Execute the SQL statement
Function query ($ n ){
Return mysql_query ($ n );
}
Function f ($ q, $ f = 1 ){
If ($ f ){
Return mysql_fetch_array ($ q );
} Else {
Return mysql_fetch_row ($ q );
}
}
// Obtain the id
Function id_in (){
Return mysql_insert_id ();
}
// Create database logs
Function log_sn ($ son = ""){
$ Son = "##". date ("Y-m-d H: I: s "). "##". mysql_error (). $ son. "\ r \ n ";
$ Fp = fopen (date (ymd). ". txt", );
Fwrite ($ fp, $ son );
Fclose ($ fp );
}
}

Subclass:
Class act extends mysql {
Function insert ($ tb, $ var, $ state = 0 ){
$ SQL = "insert into". $ tb. "set". $ var;
If ($ state ){
Echo $ SQL;
} Else {
Mysql_query ($ SQL );
// Return $ this-> id_in ();
}
}

Page:
Include ('MySQL. class. php ');
Include ('Act. class. php ');
$ Insert = new act ("localhost", "root", "", "news", "gbk ");
$ Insert-> insert ("news", "comment", sort = '2', hit = '0', adtime = 130229197, uptime = 1302292988, del = 'n '");


After the page is executed, the database is not inserted successfully and no error is reported. However, the printed SQL statements can be used in the database. Is it a mysql version problem? Or is there a problem with my code?

------ Solution --------------------
Input parameter "news", "comment", sort = '2', hit = '0', adtime = 130229197, uptime = 1302292988, del = 'n '"

Construct an SQL string
$ SQL = "insert into". $ tb. "set". $ var;
The result is as follows:
Insert intonewssetid = null, title = ......
It's all stuck together. can it be nice?

In addition, if your id is an auto-increment field, do not write it.

------ Solution --------------------
Insert a table:
Insert into table (field) VALUES (field_value );
Modify a table:
Update table set field = new_value WHERE field = field_value;
------ Solution --------------------
"But the printed SQL statements can be used in the database"

What is printed?

According to the manual, insert... set... is supported in the latest 5.6 version, no problem
So you have to check your program.

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.