$username = "root";
$password = "";
$hostname = "localhost";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
if ($dbhandle) {
echo 'conected';
} else {
echo 'not conected WITH DATABASE';
}
mysql_select_db('data');
$indentdata= "INSERT INTO indentname (deskno, fileno, indentdate, receivedate, indentorid, projectleaderid, division, estimatedcost, convertedcost, item, projectno, cprojectno, projectname, budgethead, cashcode, nature, is_delete) VALUES ('".$_POST['deskno']."','".$_POST['fileno']." ', '".$_POST['indentdate']." ', ' ".$_POST['receivedate']." ', ' ".$_POST['indentorname']." ' , ' ".$_POST['projectleader']." ' , ' ".$_POST['estimatedcost']." ', ' ".$_POST['convertedtedcost']." ' , ' ".$_POST['item']." ', ' ".$_POST['projectno']." ', ' ".$_POST['conprojectno']."',' ".$_POST['projectname']." ',' ".$_POST['budgethead']." ',' ".$_POST['cashcode']." ',' ".$_POST['nature']." ',0)";
mysql_query($indentdata);
在这里,我已经尝试过上面的代码插入。但插入查询不起作用。请给我插入建议。记录没有插入,但也没有给出任何错误插入查询不工作在PHP?
曾听说过sql注入!这是一个很好的例子。你连接到数据库? – lordkain
同意,但回答这个问题..你能够连接,选择数据或插入任何数据库表? – JustBaron
首先,停止使用mysql_ *函数。它们自2年起不再使用,不再支持。改为使用mysqli_ *或PDO_ *。第二点,你应该看看准备好的陈述。当你这样做时,你的数据库可能会在几秒钟内被SQL注入攻击。 Btw:你有17个属性,但只有16个值。属性“分区” – Twinfriends