質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

2回答

1949閲覧

事業者情報の更新がうまくいかない

rura

総合スコア70

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2016/10/05 13:12

###前提・実現したいこと
会員情報の書き方の練習をしています。
フォームから登録した内容を更新するやり方をやってますが、
なぜかうまくいきません。
■■な機能を実装中に以下のエラーメッセージが発生しました。

###発生している問題・エラーメッセージ

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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

rura

2016/10/06 04:26

<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); $dsn = 'mysql:dbname=mfdb;host=localhost'; $user = 'root'; $password = ''; try { if (filter_input_array(INPUT_POST)) { $branchname1 = filter_input(INPUT_POST, 'branchname1'); $branchname2 = filter_input(INPUT_POST, 'branchname2'); $branchNum1 = filter_input(INPUT_POST, 'branchNum1'); $companynames = filter_input(INPUT_POST, 'companynames'); $branchmanager1 = filter_input(INPUT_POST, 'branchmanager1'); $branchmanager2 = filter_input(INPUT_POST, 'branchmanager2'); $bmssaname1 = filter_input(INPUT_POST, 'bmssaname1'); $bmssaname2 = filter_input(INPUT_POST, 'bmssaname2'); $bmssapass = filter_input(INPUT_POST, 'bmssapass'); $branchemail = filter_input(INPUT_POST, 'branchemail'); $branchtel1 = filter_input(INPUT_POST, 'branchtel1'); $branchfax1 = filter_input(INPUT_POST, 'branchfax1'); $branchzip1 = filter_input(INPUT_POST, 'branchzip1'); $branchprefecture = filter_input(INPUT_POST, 'branchprefecture'); $branchaddress = filter_input(INPUT_POST, 'branchaddress'); $branchadbill = filter_input(INPUT_POST, 'branchadbill'); $err = array(); if (empty($branchname1)) { $err['branchname1'] = "支店名を入力してください"; } if (empty($branchname2)) { $err['branchname2'] = "支店名 (フリガナ)を入力してください"; } if (empty($branchNum1)) { $err['branchNum1'] = "支店事業者番号を入力してください"; } if (empty($companynames)) { $err['companynames'] = "本店事業所名を入力してください"; } if (empty($branchmanager1)) { $err['branchmanager1'] = "支店代表名を入力してください"; } if (empty($branchmanager2)) { $err['branchmanager2'] = "支店代表名 (フリガナ)を入力してください"; } if (empty($bmssaname1)) { $err['bmssaname1'] = "支店システム管理委託者を入力してください"; } if (empty($bmssaname2)) { $err['bmssaname2'] = "支店システム管理委託者(フリガナ)を入力してください"; } if (empty($bmssapass)) { $err['bmssapass'] = "支店システム管理者用パスワードを入力してください"; } if (empty($branchemail)) { $err['branchemail'] = "支店メールアドレスを入力してください"; } if (empty($branchtel1)) { $err['branchtel1'] = "支店電話番号を入力してください"; } if (empty($branchfax1)) { $err['branchfax1'] = "支店FAX番号を入力してください"; } if (empty($branchzip1)) { $err['branchzip1'] = "支店郵便番号 を入力してください"; } if (empty($branchprefecture)) { $err['branchprefecture'] = "支店所在地を入力してください"; } if (empty($branchaddress)) { $err['branchaddress'] = "支店住所を入力してください"; } if (empty($branchadbill)) { $err['branchadbill'] = "支店ビルを入力してください"; } // エラーの数を数えて、エラーがなければインサート if (0 == count($err)) { $db = new PDO($dsn, $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); $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(); //$registered = mysqli_affected_rows($db); echo "<h4> 登録完了です</h4>"; } } }catch (PDOException $e) { $err['all'] = $e->getMessage(); } ?> <?php if (isset($err) && 0 < count($err)) : ?> <p><?= nl2br(implode(PHP_EOL, $err)); ?></p> <?php endif; ?> <?php if (isset($err) && 0 < count($err)) : ?> <p><?= nl2br(implode(PHP_EOL, $err)); ?></p> <?php endif; ?> <form method="post" action="#" 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="mssapass"><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="email" 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="tel1" 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/
guest

回答2

0

{ } の開始・終了の数を数えましょう。正しければ一致します。


ツッコミどころが相変わらず多数見受けられますが…
すでに指摘したことばかりなので、割愛します。
他の回答者からも同様に指摘されていることですから。

投稿2016/10/05 13:26

編集2016/10/05 19:34
退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

rura

2016/10/06 02:50

<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); $dsn = 'mysql:dbname=mfdb;host=localhost'; $user = 'root'; $password = ''; try { if (filter_input_array(INPUT_POST)) { $branchname1 = filter_input(INPUT_POST, 'branchname1'); $branchname2 = filter_input(INPUT_POST, 'branchname2'); $branchNum1 = filter_input(INPUT_POST, 'branchNum1'); $companynames = filter_input(INPUT_POST, 'companynames'); $branchmanager1 = filter_input(INPUT_POST, 'branchmanager1'); $branchmanager2 = filter_input(INPUT_POST, 'branchmanager2'); $bmssaname1 = filter_input(INPUT_POST, 'bmssaname1'); $bmssaname2 = filter_input(INPUT_POST, 'bmssaname2'); $bmssapass = filter_input(INPUT_POST, 'bmssapass'); $branchemail = filter_input(INPUT_POST, 'branchemail'); $branchtel1 = filter_input(INPUT_POST, 'branchtel1'); $branchfax1 = filter_input(INPUT_POST, 'branchfax1'); $branchzip1 = filter_input(INPUT_POST, 'branchzip1'); $branchprefecture = filter_input(INPUT_POST, 'branchprefecture'); $branchaddress = filter_input(INPUT_POST, 'branchaddress'); $branchadbill = filter_input(INPUT_POST, 'branchadbill'); $err = array(); if (empty($branchname1)) { $err['branchname1'] = "支店名を入力してください"; } if (empty($branchname2)) { $err['branchname2'] = "支店名 (フリガナ)を入力してください"; } if (empty($branchNum1)) { $err['branchNum1'] = "支店事業者番号を入力してください"; } if (empty($companynames)) { $err['companynames'] = "本店事業所名を入力してください"; } if (empty($branchmanager1)) { $err['branchmanager1'] = "支店代表名を入力してください"; } if (empty($branchmanager2)) { $err['branchmanager2'] = "支店代表名 (フリガナ)を入力してください"; } if (empty($bmssaname1)) { $err['bmssaname1'] = "支店システム管理委託者を入力してください"; } if (empty($bmssaname2)) { $err['bmssaname2'] = "支店システム管理委託者(フリガナ)を入力してください"; } if (empty($bmssapass)) { $err['bmssapass'] = "支店システム管理者用パスワードを入力してください"; } if (empty($branchemail)) { $err['branchemail'] = "支店メールアドレスを入力してください"; } if (empty($branchtel1)) { $err['branchtel1'] = "支店電話番号を入力してください"; } if (empty($branchfax1)) { $err['branchfax1'] = "支店FAX番号を入力してください"; } if (empty($branchzip1)) { $err['branchzip1'] = "支店郵便番号 を入力してください"; } if (empty($branchprefecture)) { $err['branchprefecture'] = "支店所在地を入力してください"; } if (empty($branchaddress)) { $err['branchaddress'] = "支店住所を入力してください"; } if (empty($branchadbill)) { $err['branchadbill'] = "支店ビルを入力してください"; } // エラーの数を数えて、エラーがなければインサート if (0 == count($err)) { $db = new PDO($dsn, $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); $sql = "UPDATE branch SET"; $sql .= "branchid='$branchid',branchname1='$branchname1',branchname2='$branchname2',branchNum1='$branchNum1',companynames='$companynames',branchmanager1='$branchmanager1',branchmanager2='$branchmanager2',bmssaname1='$bmssaname1',bmssaname2='$bmssaname2' ,bmssapass='$bmssapass',branchemail='$branchemail',branchtel1='$',branchfax1='$branchfax1',branchzip1='$branchzip1',branchprefecture='$branchprefecture',branchaddress='$branchaddress',branchadbill= '$branchadbill'; $sql .= ":branchname1,:branchname2,:branchNum1,:companynames,:branchmanager1,:branchmanager2,:bmssaname1,:bmssaname2,:bmssapass,:branchemail,:branchtel1,:branchfax1,:branchzip1,:branchprefecture,:branchaddress,:branchadbill"; $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(); //$registered = mysqli_affected_rows($db); echo "<h4> 登録完了です</h4>"; } } }catch (PDOException $e) { $err['all'] = $e->getMessage(); } ?> <?php if (isset($err) && 0 < count($err)) : ?> <p><?= nl2br(implode(PHP_EOL, $err)); ?></p> <?php endif; ?> <?php if (isset($err) && 0 < count($err)) : ?> <p><?= nl2br(implode(PHP_EOL, $err)); ?></p> <?php endif; ?>
kei344

2016/10/06 03:10

To: ruraさん コメント欄にコードを書かず、質問文にコードブロックで追記されてはいかがでしょうか。また、何のコメントも無くコードを貼り付けてしまわれると何がしたいのかがわかりませんので補足されてはいかがでしょう。
退会済みユーザー

退会済みユーザー

2016/10/06 05:02

何れにしても、学習効果が見られませんね‥
rura

2016/10/06 05:34

https://drive.google.com/open?id=0B78CozxbA3b9dmxCUWlscUctNUU ここの支店登録情報の更新URLから内容を表示できるようにした跡に 住所などを変更できるようにしたいのです。 コメント欄にコードを書かず、質問文にコードブロックで追記されてはいかがでしょうか。 パソコンが不調かうまく出来ないので、コメント欄に書いてます
kei344

2016/10/06 05:37

To: ruraさん 「何のためにコードを載せたのか」を書く必要があります。
退会済みユーザー

退会済みユーザー

2016/10/06 05:39

技術的な進歩が見られないのは百歩譲っても、質問の仕方くらい進歩しないものでしょうかね。
rura

2016/10/06 06:07

重度のアスペルガーとADHDと生まれつき健常者より10分の一以上学習能力と記憶メモリーがないがないので、ご勘弁下さい
guest

0

ベストアンサー

括弧の対応や行末のセミコロン忘れ等かと思われますが、抜粋された一部のコードでは原因の特定はできかねます。

投稿2016/10/06 00:47

ttyp03

総合スコア16998

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問