PHP connection MySQL database (Sina cloud SAE)

Source: Internet
Author: User
Tags svn

Sina Cloud provides a free service to create server-side applications. The website is: https://www.sinacloud.com/

Create a good app on it, and then write your app's code locally using Notepad as follows:

<? PHP Echo "Helloworld!" ;? >

This is one of the simplest behind the code, write well after save off, and then use SVN to upload to the app you just created. Open the URL to see the output HelloWorld this sentence.

Operational database:

1, create a shared MySQL database under the application, create a good will be shown as follows:

See the Sina Cloud website for a sample of how PHP operates the database:

API User manual SAE's PHP operating environment provides a standardMySQL, mysqli, and PDO modules to connect to the database and support all MySQL features, you can manipulate the database in the way you used to. here are some predefined constants related to sharing the MySQL database service, which you can directly reference to connect to the database: user name:sae_mysql_user Password:sae_mysql_pass Main Library domain name:sae_mysql_host_m from the library domain name:sae_mysql_host_s Port:Sae_mysql_port Database name:sae_mysql_db use method, take MYSQL module as an example: <?PHP//even the main library$db=mysql_connect(sae_mysql_host_m. ': '). Sae_mysql_port,sae_mysql_user,sae_mysql_pass);//Connect from library//$db = mysql_connect (sae_mysql_host_s. ': '). Sae_mysql_port,sae_mysql_user,sae_mysql_pass);if($db) {    mysql_select_db(sae_mysql_db,$db); // ...}?>Note PDO does not support host:p ORT this notation, use the PDO standard notation

That's clear: Here are some predefined constants related to sharing the MySQL database service, and you can directly reference these parameters to connect to the database:

In other words, Sina has helped you to your main library address, from the library address, database name, and so has been defined as a macro definition, you directly use the following code, you do not need to replace the inside of the sae_mysql_host_m to its own main library address

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

That is to say your code is < ph

// even the main library $db mysql_connect (sae_mysql_host_m. ': '). Sae_mysql_port,sae_mysql_user,sae_mysql_pass); if ($db) {   //  mysql_select_db (sae_mysql_db, $db);

Echo ' OK '// ...
}

Else
Echo ' Error '

?>

After writing the code, use SVN to upload to the cloud, and then click Cross-app authorization to the app in the created shared MySQL database management, then you can access it through the web.

PHP connection MySQL database (Sina cloud SAE)

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.