我想從表單獲取數據並將其發送到我的數據庫,即phpmyadmin。代碼在本地正常工作,但在服務器上上傳時無法正常工作。 我使用本地主機作爲我的主機名連接到服務器上的數據庫,因爲我正在使用(Linux)Cpanel。代碼工作在本地但不能在服務器上工作
的代碼如下:
<?php
if(isset($_POST['name']))
{
$seniorstar=mysql_connect("localhost","username","password");
if(!$seniorstar)
{
die("Cannot Connect:".mysql_error());
}
$name=$_POST['name'];
$testimony=$_POST['testimony'];
mysql_select_db("seniorstarsdb",$seniorstar);
$sql="INSERT INTO testimonial (name,testimony) VALUES ('$name','$testimony')";
$result=mysql_query($sql,$seniorstar);
mysql_close($seniorstar);
header('Location: thank-you.html');
}
?>
正從形式牽強,但沒有被插入database.Please幫助即時通訊新的PHP 其得到執行的數據,直到謝謝頁面,但數據沒有被插入..
您日誌中的一些錯誤?你做了一些SQL注入,你應該通知你。 – Stony 2014-10-28 08:59:42
'mysql'壞習慣使用'mysqli'或更好'PDO'! – Rizier123 2014-10-28 09:00:30
嘗試爲'connect()'添加'或die()'你創建了數據庫嗎?用戶名和密碼是否正確?是授予使用該數據庫的用戶(用於插入,刪除,更新...) – Yazan 2014-10-28 09:01:33