我插入了一些數據,但沒有插入下面的代碼。我已經檢查了每個東西回聲$_REQUEST
數據一切都很好輸出,但不插入數據插入SQL查詢未成功執行
用此代碼。我從形式
$bname =$_REQUEST['bname'];
$btype =$_REQUEST['btype'];
$bemail =$_REQUEST['bemail'];
$bwebsite =$_REQUEST['bwebsite'];
$bphone =$_REQUEST['bphone'];
$bpostal =$_REQUEST['bpostal'];
$bcountry =$_REQUEST['bcountry'];
$bannertype =$_REQUEST['bannertype'];
$bgcolor =$_REQUEST['bgcolor'];
$bheadcolor =$_REQUEST['bheadcolor'];
$bsubheadcolor =$_REQUEST['bsubheadcolor'];
$btextcolor =$_REQUEST['btextcolor'];
它獲取與此
echo "$bname, $btype, $bemail, $bwebsite, $bphone, $bpostal, $bcountry, $bannertype,
$bgcolor, $bheadcolor,$bsubheadcolor,$btextcolor";
容易呼應抓取數據,但是當它涉及到插入不工作給予錯誤
include 'dbconnect.php';
$sql="insert into company (business_id, business_name, business_type, bunsiness_email,
business_website, work_phone, postal_code, business_country,banner_type,
select_bgcolor, select_heading1, select_heading2, select_text) values
('NULL','".$bname."','".$btype."','".$bemail."','".$bwebsite."', '".$bphone."',
'".$bpostal."', '".$bcountry."','".$bannertype."', '".$bgcolor."', '".$bheadcolor."',
'".$bsubheadcolor."', '".$btextcolor."')";
mysql_query($sql) or die("An Error Occured while updating");
include 'dbclose.php';*/
,這是我的表說明
+----------------------------+---------------+------+-----+---------+-----------
-----+
| Field | Type | Null | Key | Default | Extra
|
+----------------------------+---------------+------+-----+---------+-----------
-----+
| business_id | int(10) | NO | PRI | NULL | auto_increment |
| business_name | varchar(50) | NO | | NULL ||
| business_type | varchar(50) | NO | | NULL | |
| business_email | varchar(50) | NO | | NULL |
| business_website | varchar(50) | NO | | NULL |
| work_phone | varchar(20) | NO | | NULL |
| postal_code | varchar(20) | NO | | NULL |
| business_country | varchar(20) | NO | | NULL |
| banner_type | varchar(50) | NO | | NULL |
| select_bgcolor | varchar(50) | NO | | NULL |
| select_heading1 | varchar(50) | NO | | NULL |
| select_heading2 | varchar(50) | NO | | NULL |
| select_text | varchar(50) | NO | | NULL |
[**在新的代碼,請不要使用'mysql_ *'功能**](http://bit.ly/phpmsql)。他們不再被維護[並被正式棄用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**紅框**](http://j.mp/Te9zIL)?學習[*準備的語句*](http://j.mp/T9hLWi),並使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [這篇文章](http://j.mp/QEx8IB)將幫助你決定哪個。如果你選擇PDO,[這裏是一個很好的教程](http://j.mp/PoWehJ)。 – 2013-02-11 12:44:05
使用'mysql_error()'輸出錯誤。 – Sirko 2013-02-11 12:44:13
此外,您可以[SQL注入](http://stackoverflow.com/q/60174) – 2013-02-11 12:44:23