2013-06-11 111 views
0

這很可能是我只是愚蠢的東西,但我找不到我的代碼似乎出錯了。我正在嘗試爲內部的編輯頁面準備SQL UPDATE命令(是的,我知道我不是在當前版本的PHP中編寫代碼 - 工作需要快速修復,它需要一個內部系統 - 請不要評論我!)數據庫,無論我做什麼,我總是面臨一個錯誤,我被告知我有一個額外的;在我的發言中。然而,我將要發佈的UPDATE命令幾乎完全相同(除了幾個字段),我已經爲其他地方的數據庫幾乎完全相同的部分做好了準備,而且這種方法非常完美!我覺得我只是在某處丟失了一些標點符號,但我一直在盯着它幾個小時,所以我希望別人能看到。我真的發表了整個代碼塊,而不僅僅是UPDATE語句,以防萬一....顯示在這一行錯誤需要幫助查找編碼錯誤

<?php 
require("header.php"); 
$error_feat_id = ""; 
$valid_feature = ""; 
$error_feat_id = ""; 
$refferal_feat_id = $_GET['feat_id']; 
if(isset($refferal_feat_id) == TRUE) { 
    if(is_numeric($refferal_feat_id) == FALSE) { 
     $error_feat_id = 1; 
    } 
    if($error_feat_id == 1) { 
     header("Location: ".$config_basedir); 
    } 
    else { 
     $valid_feature = $refferal_feat_id; 
    } 
} 
else { 
    $valid_feature = 0; 
} 

if($_POST['submit']) { 
    $datereceived = $_POST['calendaryear']."-".$_POST['calendarmonth']."-".$_POST['calendarday']; 
    $director1dob = $_POST['director1year']."-".$_POST['director1month']."-".$_POST['director1day']; 
    $director2dob = $_POST['director2year']."-".$_POST['director2month']."-".$_POST['director2day']; 
    $update_feature_sql = "UPDATE features SET Title = '".mysql_real_escape_string($_POST['title'])."', 
    DateReceived = STR_TO_DATE(".$datereceived.", '%Y-%m-%d'), 
    Synopsis = '".mysql_real_escape_string($_POST['synopsis'])."', 
    LogLine = '".mysql_real_escape_string($_POST['logline']."', 
    StrandID = ".$_POST['programstrand'].", 
    CompCatID = ".$_POST['compcat'].", 
    PremiereID = ".$_POST['premierestatus'].", 
    FirstFeatureID = ".$_POST['firstfeature'].", 
    OriginID = ".$_POST['origin'].", 
    RoughtCutID = ".$_POST['roughcut'].", 
    ScreenerID = ".$_POST['screener'].", 
    Director1 = '".mysql_real_escape_string($_POST['director1'])."', 
    Director1Bio = '".mysql_real_escape_string($_POST['director1bio'])."', 
    Director1Nationality = '".mysql_real_escape_string($_POST['director1nation'])."', 
    Director1DOB = STR_TO_DATE(".$director1dob.", '%Y-%m-%d'), 
    Director2 = '".mysql_real_escape_string($_POST['director2'])."', 
    Director2Bio = '".mysql_real_escape_string($_POST['director2bio'])."', 
    Director2Nationality = '".mysql_real_escape_string($_POST['director2nation'])."', 
    Director2DOB = STR_TO_DATE(".$director2dob.", '%Y-%m-%d'), 
    Country1 = '".mysql_real_escape_string($_POST['country1'])."', 
    Country2 = '".mysql_real_escape_string($_POST['country2'])."', 
    Country3 = '".mysql_real_escape_string($_POST['country3'])."', 
    Country4 = '".mysql_real_escape_string($_POST['country4'])."', 
    Country5 = '".mysql_real_escape_string($_POST['country5'])."', 
    Country6 = '".mysql_real_escape_string($_POST['country6'])."', 
    Country7 = '".mysql_real_escape_string($_POST['country7'])."', 
    Country8 = '".mysql_real_escape_string($_POST['country8'])."', 
    Country9 = '".mysql_real_escape_string($_POST['country9'])."', 
    Country10 = '".mysql_real_escape_string($_POST['country10'])."', 
    Cast1 = '".mysql_real_escape_string($_POST['cast1'])."', 
    Cast2 = '".mysql_real_escape_string($_POST['cast2'])."', 
    Cast3 = '".mysql_real_escape_string($_POST['cast3'])."', 
    Cast4 = '".mysql_real_escape_string($_POST['cast4'])."', 
    AdditionalComments = '".mysql_real_escape_string($_POST['additionalcomments'])."', 
    DurationHours = '".mysql_real_escape_string($_POST['durationhours'])."', 
    DurationMins = '".mysql_real_escape_string($_POST['durationmins'])."', 
    ScreeningFormat1 = ".$_POST['screeningformat1'].", 
    ScreeningFormat2 = ".$_POST['screeningformat2'].", 
    ScreeningFormat3 = ".$_POST['screeningformat3'].", 
    ScreeningFormat4 = ".$_POST['screeningformat4'].", 
    ScreeningFormat5 = ".$_POST['screeningformat5'].", 
    DCPEID = ".$_POST['dcpe'].", 
    DCPCPL = '".mysql_real_escape_string($_POST['dcpcpl'])."', 
    SubTypeID = ".$_POST['subtype'].", 
    AspectID = ".$_POST['aspect'].", 
    LanguageID = ".$_POST['language'].", 
    SubtitlesID = ".$_POST['subtitles'].", 
    AudioID = ".$_POST['audio'].", 
    PubRecID = ".$_POST['pubrec'].", 
    TypeOfMaterials = '".mysql_real_escape_string($_POST['typeofmaterials'])."', 
    ContactName = '".mysql_real_escape_string($_POST['contactname'])."', 
    ContactEmail = '".mysql_real_escape_string($_POST['contactemail'])."', 
    ContactPhone1 = '".mysql_real_escape_string($_POST['contactphone1'])."', 
    ContactPhone2 = '".mysql_real_escape_string($_POST['contactphone2'])."', 
    ContactAddress = '".mysql_real_escape_string($_POST['contactaddress'])."', 
    HomeAddressID = ".$_POST['homeaddress'].", 
    ContactWebsite = '".mysql_real_escape_string($_POST['contactwebsite'])."', 
    SAERecID = ".$_POST['saerec'].", 
    SAERetID = ".$_POST['saeret'].", 
    FeeStatusID = ".$_POST['feestatus'].", 
    EntryFeeID = ".$_POST['entryfee'].", 
    ProdYearID = '".mysql_real_escape_string($_POST['prodyear'])."', 
    ProdCo1 = '".mysql_real_escape_string($_POST['prodco1'])."', 
    ProdWebsite1 = '".mysql_real_escape_string($_POST['prodwebsite1'])."', 
    ProdCo1Nation = '".mysql_real_escape_string($_POST['prodco1nation'])."', 
    ProdCo2 = '".mysql_real_escape_string($_POST['prodco2'])."', 
    ProdWebsite2 = '".mysql_real_escape_string($_POST['prodwebsite2'])."', 
    ProdCo2Nation = '".mysql_real_escape_string($_POST['prodco2nation'])."', 
    Producer1 = '".mysql_real_escape_string($_POST['producer1'])."', 
    Producer1Nation = '".mysql_real_escape_string($_POST['producer1nation'])."', 
    Producer2 = '".mysql_real_escape_string($_POST['producer2'])."', 
    Producer2Nation = '".mysql_real_escape_string($_POST['producer2nation'])."', 
    Producer3 = '".mysql_real_escape_string($_POST['producer3'])."', 
    Producer3Nation = '".mysql_real_escape_string($_POST['producer3nation'])."', 
    Producer4 = '".mysql_real_escape_string($_POST['producer4'])."', 
    Producer4Nation = '".mysql_real_escape_string($_POST['producer4nation'])."', 
    SalesAgent = '".mysql_real_escape_string($_POST['salesagent'])."', 
    Distributor = '".mysql_real_escape_string($_POST['distributor'])."', 
    TalentAttached = '".mysql_real_escape_string($_POST['talentattached'])."', 
    PreviouslyScreenedAt = '".mysql_real_escape_string($_POST['prevscreenat'])."', 
    ScreeningFeesID = ".$_POST['screeningfees'].", 
    ScreeningFeesAmt = '".mysql_real_escape_string($_POST['screeningfeesamt'])."', 
    KidsID = ".$_POST['kids'].", 

代碼

ConfirmID = ".$_POST['confirm']." WHERE ID = ".$refferral_feat_id.";"; 


mysql_query($update_feature_sql) or die(mysql_error()); 
header("Location: ".$config_basedir."feat_show.php?feat_id=".$refferal_feat_id); 
} 
else { 
    $sql_get_feature = "SELECT * FROM features WHERE ID = ".$refferal_feat_id.";"; 
    $query_get_feature = mysql_query($sql_get_feature); 
    $rows_get_feature = mysql_fetch_assoc($query_get_feature); 
?> 

我意識到,我我可能會忽視某些東西,並且我可能會更有效地做事,但我是一個PHP noob,他一下子就有幾件事情,並且可以真正做到讓代碼工作!預先感謝任何幫助/建議!

+1

突出顯示的語法頗具啓發性,您不覺得嗎? :) –

+0

ConfirmID應該是什麼值? – JonnyS

+0

你會得到一個PHP語法錯誤,或者一個SQL? –

回答

1

你的第二個代碼塊中的第一行有5個雙引號。你的字符串沒有被終止。

+1

我猜這是第一塊的延續,OP的評論塞在中間。 –

0

好吧,它看起來像你有額外的;你有沒有嘗試過?

ConfirmID = $_POST['confirm']." WHERE ID = ".$refferral_feat_id; 
0

這似乎是錯誤

ConfirmID = ".$_POST['confirm']." WHERE ID = ".$refferral_feat_id.";"; 

嘗試改變它:

ConfirmID = $_POST['confirm']." WHERE ID = ".$refferral_feat_id; 
+0

它不能是這個更正,因爲字符串已經開始了上面的許多行,並且我使用雙引號來分解我想要輸入到數據庫的PHP變量。 –

0

好吧考慮到ConfirmID是上面所定義的字符串的一部分。

.$_POST['kids'].", ConfirmID = ".$_POST['confirm']." WHERE ID = ".$refferral_feat_id; 

我相信下面的行應該工作。傳遞給mysql_query()的SQL查詢不會以分號結尾。

ConfirmID = ".$_POST['confirm']." WHERE ID = ".$refferral_feat_id;