SAE MySQL Connection Instance program code

Source: Internet
Author: User
Tags learn php mysql in

Sae

Have to say, I think the SAE do the Cloud Bean payment system is two, has been a kind of let me play online illusion ... This does not mention, anyway, I think the SAE does not intend to open to free users, the estimated after the beta will not be free cloud beans can be taken, now I can use a day, then the matter will not worry about.

But for me as a novice, the SAE does a pretty good job. SAE with a php+mysql environment, and the best is an online editor, can directly edit the code, this is a novice to learn the artifact of PHP ah.

Think about it, a good php+mysql environment, but also directly modify the PHP file code, with a dual-line server. And most importantly, it's all free! In the beginning I should not be in the local environment, directly on the SAE to learn PHP on it. If someone wants to learn PHP later, I would strongly recommend using the SAE directly.

But, I also want to say but, the SAE provides the document really is very few ah ... Maybe it was my novice who didn't have a job, and it took me half an hour to find a way to access MySQL, and I found it in the sample code. It's kind of depressing.

Access to MySQL in SAE

Sample code:

The code is as follows Copy Code

$con = mysql_connect (sae_mysql_host_m. ': '. Sae_mysql_port,sae_mysql_user,sae_mysql_pass);

User name: Sae_mysql_user
Password: sae_mysql_pass
Main Library domain name: sae_mysql_host_m
From library domain name: sae_mysql_host_s
Port: Sae_mysql_port
Database name: sae_mysql_db

Note: The CREATE datebase operation cannot be performed in the SAE.
In the SAE MySQL database, only one database can operate, the name is: App_ (your application name)

My test code: (Accessing the database and creating a data table named persons)

  code is as follows copy code

$con = MySQL _connect (sae_mysql_host_m. ': '. Sae_mysql_port,sae_mysql_user,sae_mysql_pass);

mysql_select_db ("app_***", $con);
$sql = "CREATE TABLE Persons (
FirstName varchar (),
LastName varchar (),
Age int
)";
mysql_query ($sql, $con);

 

Related Article

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.