Home > Backend Development > PHP Tutorial > Code to establish a connection between php and mysql and execute SQL statements_PHP tutorial

Code to establish a connection between php and mysql and execute SQL statements_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:26:51
Original
1048 people have browsed it

Today I wrote a small program, which is very small. It can only establish a link between php and mysql and implement simple SQL statements.

Novices are trying it out for the first time, so please give guidance to experts from all walks of life.

The program source code is as follows:

Copy code The code is as follows:

$conn = mysql_connect("localhost","root","") or die ("wrong!");
$sel=mysql_select_db("mydb",$conn);
$sql="INSERT INTO `mydb`.`test` (
`id` ,
`uid` ,
`regdate` ,
`remark`
)
VALUES (
'', 'php200', now( ) , 'dddd'
) ";
$que=mysql_query($sql,$conn);
if($que)
echo "true";
else
echo "wrong";
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323864.htmlTechArticleI wrote a small program today. It is very small. It can only establish a link between php and mysql, and Implement simple SQL statements. If you are a novice trying it out for the first time, please ask experts from all walks of life for guidance. Program source...
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template