【发布时间】:2014-07-16 11:35:37
【问题描述】:
我正在尝试使用表单将一些数据插入到我的数据库中。填写表格后,我正在使用 method="POST" 获取数据。尽管我无法将表单中的数据插入数据库,但我没有语法错误。
这是一些php的代码:
<?php
// Connects to your Database
$con = mysql_connect("localhost", "root", "134711Kk", "eam3");
error_reporting(E_ALL);
ini_set('display_errors', 1);
//This is the directory where images will be saved
$target = "dokupload/";
$target = $target . basename( $_FILES['photo']['name']);
echo $target;
echo "<br>";
$name=$_POST['nameMember'];
$bandMember=$_POST['bandMember'];
if(!$con)
{
die("Connection Failed".mysql_error());
}
echo "$name" . " " . "$bandMember" . "<br/>";
$sql = "INSERT INTO Grammateia(id, idruma, tmhma) VALUES ('1', '$name', '$bandMember');";
$some = mysql_query($sql, $con);
$request = mysql_query("SELECT * FROM eam3.Grammateia;", $con);
while ($row = mysql_fetch_array($request))
{
extract($row);
echo "$id" . " " . "$idruma" . " " . "$tmhma" . "<br/>";
}
.
.
.
mysql_close($con);
?>
我设法通过 mysql 工作台在我的数据库中传递了一些数据,但没有使用 php 代码。你能帮我吗?提前致谢!
【问题讨论】:
-
现在更改您的密码。并了解 PHP 的 mysql_ API 的弃用、sql 注入和prepared statements。
标签: php mysql database insert workbench