Some simple operations of php and Mysql, phpmysql_PHP tutorial

WBOY
Release: 2016-07-13 10:06:11
Original
768 people have browsed it

Some simple operations of php and Mysql, phpmysql

Post the code first

Copy code The code is as follows:



& Lt; table & gt; database -related & lt;/table & gt;


$con = mysql_connect("localhost","root","root"); //Link database
           if(!$con){
DIE ('Connection failed!'. MySQL_ERROR ()); // Determine whether it is successful
                                                                     /*        if(mysql_query("CREATE DATABASE testdb",$con)){ //Query or send commands through mysql_query
echo "testdb created successfully"; }
        else{
                                                                                                                using echo "reason for failure: " . mysql_error(); }
*/ 
mysql_select_db("testdb",$con); //Select the database you just created
               $sql = "CREATE TABLE Persons                                                                         (personID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(personID),
                         FirstName varchar(15),
                     LastName varchar(15),
Age int)
"; "; "; "; mysql_query($sql,$con); //Execute sql statement
                             
mysql_close($con); //Close the mysql connection
?>





The key content is

1. Link database
2. Create table

3. Enrich the content of the table according to needs

The above is the entire content of this article, I hope you guys will like it.

http://www.bkjia.com/PHPjc/960702.html

www.bkjia.com

truehttp: //www.bkjia.com/PHPjc/960702.htmlTechArticleSome simple operations of php and Mysql, phpmysql first paste the code and copy the code as follows: html head title database related/ title /head body php $con = mysql_connect("localhost","root","...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!