phpでmysqlの挿入、クエリ操作する方法
phpコード:
<?php
header(“Content-type: text/html; charset=utf-8");
$con=mysql_connect(“localhost","root","startnews24″);
mysql_query(“set names charset utf8");
if(!$con)
{
die('Could not connect:’.mysql_error());
}
else
{
echo “DB接続成功!";
}
?>
<?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('エラー: ' . 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'");
?>