2014-09-27 130 views
-4

我使用xamp服務器。有在插入values.The錯誤的錯誤表示: 解析錯誤:語法錯誤,意想不到的 '插入'(T_STRING)在C:\ XAMPP \ htdocs中\ App1的\ App1的\ abc.php第6行插入Mysql錯誤

<?php 
    $mail = $_POST['mail']; 
    $pas = $_POST['pass']; 
    mysql_connect("localhost","root",""); 
    mysql_select_db("abc); 
    mysql_query("INSERT INTO abc(mail,password) VALUES ('$mail','$pas')"); 
    $reg = mysql_affected_rows(); 
    echo "$reg was inserted."; 
    ?> 

回答

0

試試這個

<?php 
$link= mysqli_connect('localhost', 'root', '', 'abc'); 
$mail = $_POST['mail']; 
$pas = $_POST['pass']; 

echo $mail; 
$query="INSERT INTO abc (mail,password) VALUES ('$mail','$pas')"; 
$result= mysqli_query($link, $query) or die(mysqli_error($link)); 


if(mysqli_affected_rows($link)>0) 
{ 
    echo 'done'; 
} 
?> 
+0

它的工作!謝謝 – Ayesha 2014-09-28 04:01:14

+0

是的請..... – Ayesha 2014-09-28 04:06:05

+0

你能幫我解決這個問題嗎? http://stackoverflow.com/questions/26054408/dont-want-to-use-col-sm-for-1200px?noredirect=1#comment40867052_26054408 – Ayesha 2014-09-28 04:16:41

0
mysql_select_db("abc); 
mysql_query("INSERT INTO abc(mail,password) VALUES ('$mail','$pas')"); 

應該

mysql_select_db("abc"); 
// Make Sure you have table with name abc in abc database 
mysql_query("INSERT INTO abc (mail,password) VALUES ('$mail','$pas')"); 

有方式的數字調試它你自己喜歡

$query = mysql_query("INSERT INTO abc (mail,password) VALUES ('$mail','$pas')") or die(mysql_error()); 

而對於受影響的行:

if(mysql_affected_rows($query) > 0) { 
    // Your message 
} 
+0

我是一個傻瓜。捆綁的感謝。 – Ayesha 2014-09-27 07:01:32

+0

仍然存在問題。在$ reg中有-1而不是1? – Ayesha 2014-09-27 07:02:31