你好朋友我写了以下代码在 MySQL 中插入评论(如 Facebook),但我没有成功。请帮我。
这是html页面
<html>
<head><title>ABC</title>
</head>
<body>
<form method="GET" action="try1.php">
<input type="text" name="like">
<input type="submit" name="Comment" value="dislike">
</form>
</body>
现在这是php代码
<html>
<head><title> </title>
</head>
<body>
<?
//connecting to database
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'root';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(!$conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("try", $conn);
$a= array('comments' =>'$_GET["like"]');
mysql_query("INSERT INTO try1 (Comments) VALUES ('$a')",$conn);
echo "Record Inserted in table";
mysql_close($conn);
?>
</body>
MySQL 只是显示“数组”。它只是将“数组”存储在 MySQL 字段中请帮助我!