How to create a MySQL database by time in PHP-php Tutorial

Source: Internet
Author: User
In PHP, how does one create a MySQL database by time? This post was last edited by UniverseOS from 2013-03-1711: 34: 14. I currently have a requirement to create a database by month (that is, date (Ym, my current SQL statement: $ SQL & nbsp; CREATE & nbsp; TABLE & nbsp; IF & nbsp; NOT & nbsp; E PHP, how to CREATE a MySQL database by time?

This post was last edited by UniverseOS at 11:34:14

I currently have a requirement to create a database by month (that is, date ('ym'). my current SQL statement:
$ SQL = "CREATE TABLE IF NOT EXISTS time (file_id int (10) auto_increment primary key, filename varchar (60), filepath varchar (60), filesize int (10 ), uploadtime date )";

If you assign time = date ('ym'), an error is reported (the SQL syntax is incorrect). how can this problem be solved?


------ Solution --------------------
$ Dbtime = date ('ym ');
$ SQL = "CREATE TABLE IF NOT EXISTS '$ dbtime '(....";

In fact, it's easy to add a character before you?
$ Dbtime = 't'. date ('ym ');
$ SQL = "CREATE TABLE IF NOT EXISTS $ dbtime (....";

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.