我想知道如果我正在做一個正確的表格寫入,它似乎失敗。MySQL表格插入
while($n != 1)
{
$randstring = "live_".RandomString();
echo "<br>".$username."<br>";
echo $randstring."<br>";
$idcheck = mysql_query("SELECT * FROM streamer_ids WHERE streamer_id='".$randstring."'"); //check for matching random strings
if (!(mysql_num_rows($idcheck)>0))
{
$n=1; //It has found a random string that does not match.
}
}
//if it has reached this far, it has a unique id. Now that id is being written to the database.
$temp = mysql_query("INSERT INTO streamer_ids (username,streamer_id,premium) VALUES(".$username.",".$randstring.","0")");
$temp->closeCursor();
請注意,最後一部分被嚴重屠殺,這是我需要幫助。
1.你可以發佈你正在得到的錯誤2.強制性SQL注入警告 - 使用參數3.你對匹配隨機字符串的唯一性檢查似乎是多餘的 - 你試圖用它來實現什麼? – InSane 2010-12-09 04:09:09
它需要是完全獨特的,如果匹配的話它會繼續重新生成隨機字符串。 – 2010-12-09 04:19:48