您好我正在使用表单向查询中插入新值。
我得到的错误是:数组到字符串转换。
我应该改变什么才能得到这个错误?
谢谢
if( isset($_POST["new_log"]) ){
//mysql_real_escape_string - ochrana proti mysql injection
$name = $_POST["name"];
$surname = $_POST["surname"];
$password = $_POST["password"];
$email = $_POST["email"];
$salary = $_POST["salary"];
$msaving = $_POST["msaving"];
$mfixpayment = $_POST["mfixpayment"];
$lastupdate = $_POST["lastupdate"];
$bio = $_POST["bio"];
$money = $_POST["money"];
$new_log=" INSERT INTO login SET `name`='$name', `surname`='$surname', `password`='$password', `email`='$email', `salary`='$salary', `msaving`='$msaving', `mfixpayment`='$mfixpayment', `lastupdate`='$lastupdate', `bio`='$bio', `money`='$money' ";
mysql_query( $new_log ) or die( mysql_error() );
}
这里我按表单
插入新值 echo ' <form method="post"> ';
echo ' meno: <input type="text" name="name['. $row_log["id"] .']" > <br />';
echo ' priezvisko: <input type="text" name="surname['. $row_log["id"] .']"> <br />';
echo ' heslo: <input type="text" name="password['. $row_log["id"] .']"> <br />';
echo ' e-mail: <input type="text" name="email['. $row_log["id"] .']"> <br />';
echo ' vyplata: <input type="number" name="salary['. $row_log["id"] .']"> <br />';
echo ' chcem mesačne ušetriť <input type="number" name="msaving['. $row_log["id"] .']"> <br />';
echo ' platím každý mesiac: <input type="number" name="mfixpayment['. $row_log["id"] .']"> <br />';
echo ' posledná mena: <input type="date" name="lastupdate['. $row_log["id"] .']"> <br />';
echo ' niečo o sebe: <input type="text" name="bio['. $row_log["id"] .']"> <br />';
echo ' mám na účte: <input type="number" name="money['. $row_log["id"] .']"> <br />';
echo "<br />";
echo '<input type="submit" name="new_log" value="Pridať nového užívateľa" >';
echo '</form>';
答案 0 :(得分:2)
$name = $_POST["name"];
应该是
$name = $_POST["name"][$id];
或者,输出:
<input type="text" name="name" >
而不是
<input type="text" name="name['. $row_log["id"] .']" >