EDITED : 아래 작업 코드! 아래multi_query()를 사용할 수 없습니다.
//* opens a connection to a MySQL server */
$mysqli = new mysqli($host, $username, $password, $database);
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "INSERT INTO `test` (test1, test2) VALUES('testing','testing2222');";
$query .= "INSERT INTO `test` (test1, test2) VALUES('testing3333','testing44444');";
$query .= "INSERT INTO `test` (test1, test2) VALUES('testing5555','testing66666');";
$query .= "INSERT INTO `test` (test1, test2) VALUES('testing77777','testing888888');";
$query .= "INSERT INTO `test` (test1, test2) VALUES('testing99999','testing101010');";
if ($mysqli->multi_query($query)) {
do {
/* store first result set */
if ($result = $mysqli->store_result()) {
while ($row = $result->fetch_row()) {
//printf("%s\n", $row[0]);
}
$result->free();
}
/* print divider */
//if ($mysqli->more_results()) {
// printf("-----------------\n");
//}
} while ($mysqli->next_result());
}
/* close connection */
$mysqli->close();
BAD 코드 :
나는이 가능한 모든 방법을 시도하고 난 일하러 수없는 것. 하나의 유사 검색어가 입력 할 검색어가 하나만있는 경우에만 작동합니다. 그것이 하나 이상 있다면 그것은 실패합니다.
//* opens a connection to a MySQL server */
$mysqli = mysql_connect($host,$username,$password, $database);
$query = "INSERT INTO `test` (test1, test2) VALUES('testing','testing2222')";
$query .= "INSERT INTO `test` (test1, test2) VALUES('testing3333','testing44444')";
if($mysqli->multi_query($query))
{
do
{
if($result=$mysqli->store_result())
{
while($row=$result->fetch_row())
{
printf("%s<br/>",$row[0]);
}
$result->free();
}
if($mysqli->more_results())
{
print("-------------------------------<br/>");
}
else
{
echo '<br/>';
}
}while($mysqli->more_results() && $mysqli->next_result());
}
연결이되면, 따라하기 쉽도록 코드 일부가 다듬어졌습니다. 테이블 존재, 등 ... 또한 주요 예제를 시도, 단어, 그리고 그것을 작동하지 않는 것. 내가 어디로 잘못 가고 있니?
"INSERT"문 중 하나에 기존 테이블이 없으면 스크립트가 어떻게 반응하는지 확인하십시오. 오류 처리없이 스크립트를 사용하면 안됩니다. –