2013-10-10 25 views
-1

我有一個html格式更新字段,如usp,描述,面積等雜貨店。當我選擇任何雜貨店進行更新時,數據庫中已存在的詳細信息將被提取到html表單的文本區域,以便我可以在更新之前查看有哪些內容。使用html格式更新mysql數據庫適用於說grocerystore1但不適用於grocerystore2

讓我舉一個例子:

數據庫中的兩個雜貨店已經假設這些細節。

雜貨商店1:

usp: fresh 
description:very good store 
area: boston 

雜貨商店2:

usp:fresh products, nice store look, very good service, customer friendly, bla bla bla... 
description: located in one of the poshest places of the city this store is unique bla bla bla bla bla bla bla bla bla bla bla bla bla bla .............. 
area: boston 

現在,當我使用的HTML表單更新這些領域,它更新完美罰款雜貨商店1。但對於GROCERY STORE2它不會更新。我發現的原因是GROCERY STORE2中的文字已經太多了。然後,我去了我的數據庫,並將GROCERY STORE2的詳細信息編輯到最低限度,例如usp:good,description:nice,area,boston。現在,當我使用html表單來更新它時,它工作正常。所以,只要有太多的文字,這個HTML表單似乎不起作用。我該如何解決這個問題。在此先感謝

PHP代碼

<?php 
if (!isset($_POST['usp'])) 
{ 
//If not isset -> set with dumy value 
$_POST['usp'] = ""; 
} 

if (!isset($_POST['area_served'])) 
{ 
//If not isset -> set with dumy value 
$_POST['area_served'] = ""; 
} 

if (!isset($_POST['description'])) 
{ 
//If not isset -> set with dumy value 
$_POST['description'] = ""; 
} 




if (!isset($_POST['submit'])) 
{ 
    //If not isset -> set with dumy value 
    $_POST['submit'] = ""; 
} 

$usp = $_POST['usp']; 
$area_served = $_POST['area_served']; 
$description = $_POST['description']; 
$submit = $_POST['submit']; 
if($submit) 
{ 
$insert=mysql_query("UPDATE stores SET usp='$usp',area_served='$area_served',description='$description', WHERE store_id=$storeid"); 
header("Location:updateinfo.php?city_id=$cityid&store_id=$storeid"); 
} 
?> 

HTML代碼

<form name="myForm" action="" method="POST" action="condatabase.php" > 
    <div> 
    <label for="myname">USP*:</label> 
    <textarea name="usp" id="box1" rows="5" cols="5"><?PHP echo $record12['usp']?>  
    </textarea> 
    </div> 
    <div> 
    <label for="area_served">Areas served*:</label> 
    <textarea name="area_served" id="box1" rows="5" cols="5"><?PHP echo  
    $record12['area_served']?></textarea> 
    </div> 
    <div> 
    <label for="email">description*:</label> 
    <textarea name="description" id="box1" rows="5" cols="5"><?PHP echo  
    $record12['description']?></textarea> 
    </div> 
    <div id="thesubmit"> 
    <button class="button" input type="submit" name="submit" value="Comment" 
    />Submit</button> 
    </div> <br> 
    <div id="thesubmit"> 
    <button class="button" input type="reset" name="Reset" value="Reset" />Reset</button></div> 
    </form> 
+2

分享您的代碼 – tinybyte

+0

問題是不是在你的形式,但使用的mysql_query:1逃生輸入2.不使用的mysql_query – alandarev

+0

可以請你讓我知道我可以使用什麼而不是mysql_query。還有一件事我想問的是,爲什麼它只適用於一家商店而不適用於其他商店。是否它在提交長文本之前超時 – Bora

回答

0

我不t看你在哪裏定義$storeid變量e?可以是這個。

此外,您在WHERE之前的查詢中還有一個逗號。因此,嘗試

$insert=mysql_query("UPDATE stores SET usp='$usp',area_served='$area_served',description='$description' WHERE store_id=$storeid"); 

,而不是

$insert=mysql_query("UPDATE stores SET usp='$usp',area_served='$area_served',description='$description', WHERE store_id=$storeid"); 
+0

謝謝......但商店ID我使用$ GET獲得它,然後將它傳遞給此$ storeid。查詢工作正常......但正如我曾經說過的,如果文本不那麼只有它的作品,如果在表單中輸入的文本更多它不起作用。 – Bora

相關問題