首页 >php教程 >php手册 >常规数据库操作

常规数据库操作

WBOY
WBOY原创
2016-06-06 19:35:311258浏览

利用PHP向MySQL中插入或找出数据 无 ?phpheader("Content-type: text/html; charset=utf-8"); $con=mysql_connect("localhost","root","root");mysql_query("set names charset utf8");if(!$con){die('Could not connect:'.mysql_error());}else{echo "成功链

利用PHP向MySQL中插入或找出数据 
<?php
header("Content-type: text/html; charset=utf-8"); 
$con=mysql_connect("localhost","root","root");
mysql_query("set names charset utf8");
if(!$con)
{
die('Could not connect:'.mysql_error());	
}
else
{
echo "成功链接!";	
}
?>
<?php
require '../mode/conn.php';

$title=$_POST["select_title"];
$content=$_POST["content1"];

mysql_select_db("w3c", $con);

$sql="INSERT INTO content (content_onename, content_content)
VALUES
('$title','$content')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "成功添加;";

mysql_close($con)


?>
<?php
require 'mode/conn.php';
mysql_select_db("w3c", $con);
$result = mysql_query("SELECT * FROM content
WHERE content_onename='html/css'");

?>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn