我有我正在爲音樂評分的這個腳本,沒有錯誤,而且我得到'Data Inserted',我知道我還沒有逃脫數據,但是有沒有問題在這個腳本中可能會阻止它將插入的數據放入數據庫中?這不行?有什麼建議麼?
<?
include($_SERVER['DOCUMENT_ROOT'].'/assets/global/scripts/connect.php');
$songname = $_GET['songname'];
$artist = $_GET['artist'];
$ratenum = 1;
$chkquery = "SELECT * FROM hotmuze_music WHERE songname='$songname'";
$plusOneQuery = "SELECT * FROM hotmuze_music WHERE songname='$songname'";
$updateQuery = "UPDATE hotmuze_music SET rating='$rating2' WHERE songname='$songname'";
$checkdata = mysql_query($chkquery);
$checkrows = mysql_num_rows($checkdata);
if($checkrows==0)
{
$insquery = "INSERT INTO hotmuze_music (id, songname, artist, sex, genre, rating, promoted) VALUES('', '$songname', '$artist', '', '$genre' '$ratenum')";
$insdata = mysql_query($insquery);
}
if($checkrows!=0)
{
$plusData = mysql_query($plusOneQuery);
}
if(mysql_num_rows($plusData)!=0)
{
$result = mysql_fetch_assoc($plusData);
$rating = $result['ratng'];
$rating2 = $rating+1;
mysql_query($updateQuery);
echo "Data Inserted";
}
?>
謝謝! :)
檢查錯誤:'mysql_foo()或死亡(mysql_error());'' – Blender
$等級= $結果[「ratng '];'也許應該是'$ rating = $ result ['rating'];' – thetaiko
你插入時沒有發送'升級'列值。 '$ Genre'之後也沒有昏迷 – HRgiger