Home > Backend Development > PHP Tutorial > How to write php to execute sql statement_PHP tutorial

How to write php to execute sql statement_PHP tutorial

WBOY
Release: 2016-07-21 15:47:34
Original
1031 people have browsed it

Copy code The code is as follows:

@mysql_connect("localhost", "root","1981427" ) //You need to connect to the database server before selecting the database
or die("Database server connection failed");
@mysql_select_db("test") //Select the database mydb
or die("The database does not exist or not available");
$query = @mysql_query("select * from tablename1") //Execute SQL statement
or die("SQL statement execution failed");
?>


Copy code The code is as follows:

@mysql_connect("localhost ", "root","1981427") //You need to connect to the database server before selecting the database
or die("Database server connection failed");
@mysql_select_db("test") //Select database mydb
or die("Database does not exist or is unavailable");
$query = @mysql_query("insert into tablename1 values('4', 'Judy','456')")
or die( "SQL statement execution failed");
?>


Copy code The code is as follows:

@mysql_connect("localhost", "root","1981427") //You need to connect to the database server before selecting the database
or die("Database server connection failed") ;
@mysql_select_db("test") //Select database mydb
or die("Database does not exist or is unavailable");
$query = @mysql_query("select * from tablename1") // Execute SQL statement
or die("SQL statement execution failed");
echo mysql_result($query, 0, 'username'); //Output the name column of row 0
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319926.htmlTechArticleCopy the code as follows: ?php @mysql_connect("localhost", "root","1981427") // Before selecting the database, you need to connect to the database server or die ("Database server connection failed"); @my...
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