2015-05-26 111 views
-1

當我嘗試插入新行它給了我這個錯誤:錯誤INSERT INTO在PHP

Parse error: syntax error, unexpected ';'

當我執行查詢,我在做什麼錯?

// Selecting Database 
$db = mysql_select_db("spinbb_weedworld", $connection) or die(mysql_error($db)); 
// SQL query to fetch information of registerd users and finds user match. 
$query = "INSERT INTO login ('name','password', 'email','username') 
     VALUES ('".$name."', '".$password."', '".$email."','".$username."')"; 
$query = mysql_query($query,$db) or die(mysql_error($db); 

if ($query) 
{ 
    header("location: profile.php"); 
} 
else 
{ 
    echo("MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$query\n<br>"); 
} 

mysql_close($connection); // Closing Connection 
+1

請檢查您的標題...什麼都沒有ü可以插入到PHP – user1844933

回答

3

關閉錯字)

$query = mysql_query($query,$db) or die(mysql_error($db)); 
1

嘗試使用查詢,如下所示:

$query = "INSERT INTO login ('name','password', 'email','username') 
     VALUES ('$name', '$password', '$email','$username')";