データを追加できない; | 元気ハツラツtamagoです

元気ハツラツtamagoです

PC前を住処にしている主婦でございます。

Webクリエイターを目指す!!
今日もゴニョゴニョ中・・・・

---------------------------------------------------------------
メールフォームから入力された内容をデータベースに入れるPHPを作ってますが、全然できないのです。

初心者にもならんなwww

色々いっぺんにしようとせず、とりあえず一つのtextをdb(text)のテーブル(naiyou)の項目(naiyou)に追加しよう!!

test.php
<html>
<head>
<title>POST送信されたデータを受け取る</title>
</head>
<body>
<?php
echo "<p>入力内容(\$_POST):".@$_POST["text1"];

$hostname = "localhost";
$userid = "******";
$passwd = "*****************";

$db_link = mysql_connect($hostname,$userid,$passwd);

$db_nm = "test";
mysql_select_db($db_nm,$db_link);

$sql = "SET NAMES utf-8";
$result = mysql_query($sql,$db_link);

$sql = "INSERT INTO naiyou(naiyou), VALUES ('".$_POST["text1"]."')";
$result = mysql_query($sql,$db_link);
if($result) {
print "\nテーブルにデータを追加した\n";
}else {
$err_no = mysql_errno($db_link);
$err_msg = mysql_error($db_link);
print "エラー番号".$err_no;
print "エラーメッセージ".$err_msg;
}

mysql_close($db_link);
?>
<form method="POST" action="<?php echo $_SERVER["PHP_SELF"]?>">
<table>
<tr>
<td><input type="text" name="text1"></td>
<td><input type="submit" value="送信" name="sub1"></td>
</tr>
</table>
</form>
</body>
</html>

はい、エラー(;´Д`A ```

エラー番号1064 エラーメッセージYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' VALUES ('hogehoge')' at line 1

むむむ????