两个查询:
$reg_insert_basic_query = <<<SQL
INSERT INTO `Members` (username, password, email, api_key)
VALUES ('$nuser', '$hash', '$nemail', '$napik');
$gw2name = "name.3245";
$gw2_world_id = $epa_array[0]['world'];
$gw2_world_name = "'".$epw_array[0]['name']."'";
$gw2name = mysqli_real_escape_string($mysqli, $gw2name);
$reg_insert_basic_query = <<<SQL
INSERT INTO Members (gw2_name, WorldID, Worldname)
VALUES ($gw2name, $gw2_world_id, $gw2_world_name)
SQL;
if(!$result = $mysqli->query($reg_insert_basic_query)){
die('<br />There was an SQL error![' . $mysqli->error . ']');
}
我发现在$ gw2_name周围使用单引号可以使用或使用双引号,但是没有任何效果。我不确定如何清除“ name.3245”中的句号以使其起作用。
最佳答案
$reg_insert_basic_query = <<<SQL
UPDATE `Members`
SET gw2_name = '$gw2name', WorldID = '$gw2_world_id', Worldname = '$gw2_world_name'
WHERE ID = '$u_id'
SQL;
解决了不创建新行的问题。
关于php - MySQL查询PHP中的字符串问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34033996/