###前提・実現したいこと
会員情報の書き方の練習をしています。
フォームから登録した内容を更新するやり方をやってますが、
なぜかうまくいきません。
■■な機能を実装中に以下のエラーメッセージが発生しました。
###発生している問題・エラーメッセージ
syntax error, unexpected end of file in
###該当のソースコード
//$sql = "UPDATE branch SET name = 'YYY' where id = 4"; //execメソッドでクエリを実行。execメソッドでupdate文を実行した場合は更新件数が返る。 $sql = "UPDATE branch SET "; $sql .= "branchname1='$branchname1', branchname2='$branchname2', branchNum1='$branchNum1', companynames='$companynames', branchmanager1='$branchmanager1', branchmanager2='$branchmanager2', bmssaname1='$bmssaname1', bmssaname2='$bmssaname2', bmssapass='$bmssapass', branchemail='$branchemail', branchtel1='$branchtel1', branchfax1='$branchfax1', branchzip1='$branchzip1', branchprefecture='$branchprefecture', branchaddress='$branchaddress', branchadbill='$branchadbill' "; $sql .= "where branchid = '$branchid' "; $stmt = $db->prepare($sql); // パラメータのセットの仕方はマニュアルで確認してください。 $stmt->bindParam(':branchname1', $branchname1, PDO::PARAM_STR); $stmt->bindParam(':branchname2', $branchname2, PDO::PARAM_STR); $stmt->bindParam(':branchNum1', $branchNum1, PDO::PARAM_STR); $stmt->bindParam(':companynames', $companynames, PDO::PARAM_STR); $stmt->bindParam(':branchmanager1', $branchmanager1, PDO::PARAM_STR); $stmt->bindParam(':branchmanager2', $branchmanager2, PDO::PARAM_STR); $stmt->bindParam(':bmssaname1', $bmssaname1, PDO::PARAM_STR); $stmt->bindParam(':bmssaname2', $bmssaname2, PDO::PARAM_STR); $stmt->bindParam(':bmssapass', $bmssapass, PDO::PARAM_STR); $stmt->bindParam(':branchemail', $branchemail, PDO::PARAM_STR); $stmt->bindParam(':branchtel1', $branchtel1, PDO::PARAM_STR); $stmt->bindParam(':branchfax1', $branchfax1, PDO::PARAM_STR); $stmt->bindParam(':branchzip1', $branchzip1, PDO::PARAM_STR); $stmt->bindParam(':branchprefecture', $branchprefecture, PDO::PARAM_STR); $stmt->bindParam(':branchaddress', $branchaddress, PDO::PARAM_STR); $stmt->bindParam(':branchadbill', $branchadbill, PDO::PARAM_STR); // 実行 $stmt->execute(); $count = $db->exec($sql); //$registered = mysqli_affected_rows($db); echo "{$count}件データを更新しました。".PHP_EOL; } } }catch (PDOException $e) { $err['all'] = $e->getMessage(); } ?> <?php if (isset($err) && 0 < count($err)) : ?> <p><?= nl2br(implode(PHP_EOL, $err)); ?></p> <?php endif; ?> <form method="post" action="Branch.php" class="contact"> <table> <caption>支店登録票</caption> <tbody> <th><label for="company">支店名</label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchname1" placeholder="名古屋支店"></td> </tr> <tr> <th><label for="section">支店名 <span class="supplement">(フリガナ)</span></label></th> <td class="required"><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchname2" id="name2" placeholder="ナゴヤシテン"></td> <tr> <th><label for="section">支店事業者番号 </label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td ><input type="number" name="branchNum1"></td> </tr> <tr> <th><label for="section">本店事業所名</label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="companynames" id="section" placeholder="愛知福祉振興会じんぐう"></td> </tr> <tr> <th><label for="section">支店代表名</label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchmanager1" id="section" placeholder="愛知太郎"></td> </tr> <tr> <th><label for="section">支店代表名 <span class="supplement">(フリガナ)</span></label></th> <td class="required"><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchmanager2" id="name2" placeholder="アイチタロウ"></td> </tr> <tr> <th><label for="section">支店システム管理委託者</label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="bmssaname1" id="section" placeholder="名古屋太郎"></td> </tr> <tr> <th><label for="section">支店システム管理委託者 <br><span class="supplement">(フリガナ)</span></label></th> <td class="required"><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="bmssaname2" id="name2" placeholder="ナゴヤタロウ"></td> </tr> <tr> <th><label for="email">支店システム管理者用<br>パスワード</label></th> <td class="required"><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="password" name="bmssapass"><span class="supplement">(半角英数字)</span><br> <span class="supplement">ご入力間違いのないようにご注意ください</span></td> </tr> <tr> <th><label for="email">支店メールアドレス</label></th> <td class="required"><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchemail" id="branchemail" size="50" placeholder="(半角英数字)"> <br> <span class="supplement">ご入力間違いのないようにご注意ください</span></td> </tr> <tr> <th><label for="tel1">支店電話番号</label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchtel1" id="branchtel1" size="12"> <span class="supplement">(半角数字)</span></td> </tr> <tr> <th><label for="fax1">支店FAX番号</label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchfax1" id="fax1" size="12"> <span class="supplement">(半角数字)</span></td> </tr> <tr> <th rowspan="4"><label for="zip1">支店住所</label></th> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><label for="zip1">支店郵便番号</label> <input type="text" name="branchzip1" id="zip1" size="12"><span class="supplement">(半角数字)</span></td> </tr> <tr> <td class="required"><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><select name="branchprefecture" id="prefecture"> <option value="">都道府県の選択</option> <option value="北海道">北海道</option> <option value="青森県">青森県</option> <option value="岩手県">岩手県</option> <option value="宮城県">宮城県</option> <option value="秋田県">秋田県</option> <option value="山形県">山形県</option> <option value="福島県">福島県</option> <option value="東京都">東京都</option> <option value="神奈川県">神奈川県</option> <option value="埼玉県">埼玉県</option> <option value="千葉県">千葉県</option> <option value="茨城県">茨城県</option> <option value="栃木県">栃木県</option> <option value="群馬県">群馬県</option> <option value="山梨県">山梨県</option> <option value="新潟県">新潟県</option> <option value="長野県">長野県</option> <option value="富山県">富山県</option> <option value="石川県">石川県</option> <option value="福井県">福井県</option> <option value="愛知県">愛知県</option> <option value="岐阜県">岐阜県</option> <option value="静岡県">静岡県</option> <option value="三重県">三重県</option> <option value="大阪府">大阪府</option> <option value="兵庫県">兵庫県</option> <option value="京都府">京都府</option> <option value="滋賀県">滋賀県</option> <option value="奈良県">奈良県</option> <option value="和歌山県">和歌山県</option> <option value="鳥取県">鳥取県</option> <option value="島根県">島根県</option> <option value="岡山県">岡山県</option> <option value="広島県">広島県</option> <option value="山口県">山口県</option> <option value="徳島県">徳島県</option> <option value="香川県">香川県</option> <option value="愛媛県">愛媛県</option> <option value="高知県">高知県</option> <option value="福岡県">福岡県</option> <option value="佐賀県">佐賀県</option> <option value="長崎県">長崎県</option> <option value="熊本県">熊本県</option> <option value="大分県">大分県</option> <option value="宮崎県">宮崎県</option> <option value="鹿児島県">鹿児島県</option> <option value="沖縄県">沖縄県</option> <option value="その他">その他</option> </select></td> </tr> <tr> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchaddress" id="address" placeholder="名古屋市東区D町1-2-3"></td> </tr> <tr> <td class="required" ><img src="./img/required1.gif" alt="必須" width="26" height="15"></td> <td colspan="10"><input type="text" name="branchadbill" id="address" placeholder="○○ビル"></td> </tr> <tr> </tbody> </table> <p class="button"><input type="submit" value="登録"></p> </form>
###補足情報(言語/FW/ツール等のバージョンなど)
PHP、MYSQL
回答2件
あなたの回答
tips
プレビュー