携帯ページにアドセンスをくっつけるとエラー

このQ&Aのポイント
  • 自作blogに携帯用アドセンスのPHPコードをつけたところ、携帯ページにエラーが出力されます。
  • 広告は表示されませんでした。
  • 解決法ご存知の方いたら教えてください。
回答を見る
  • ベストアンサー

携帯ページにアドセンスをくっつけるとエラー

自作blogに携帯用アドセンスのPHPコードをつけたところ、携帯ページにエラーが出力されます Fatal error:smarty error... unrecognized tag... という具合です。 試しに<literal>で囲みました。ページは表示されましたが、広告は表示されませんでした。ほかのサイト見ても見当がつきません。 http://www.1x1.jp/blog/2007/10/google_mobile_adsense.html mobile_article.htmlというモバイル用のテンプレートです。 もちろんsmartyを使っています。 PHP拡張子でないのがいけないようですが、smarty使っている以上、htmlから変更できません。 解決法ご存知の方いたら教えてください。 よろしくお願いします。

  • PHP
  • 回答数1
  • ありがとう数1

質問者が選んだベストアンサー

  • ベストアンサー
  • umomom
  • ベストアンサー率100% (1/1)
回答No.1

このページのやり方では解決できないでしょうか?

参考URL:
http://afilikasegu.seesaa.net/article/114180953.html
Scotty_99
質問者

お礼

回答ありがとうございました。 拡張子が.htmlなのでPHPソースを入れただけではだめみたいです。

関連するQ&A

  • テンプレートの.htmlにPHPソースを入れる

    Smartyを使っています。 templateフォルダーにある、.htmlファイルにPHPソースを埋め込むと当然ではありますが、Smarty errorになります。unrecognized tagとでます。 .htmlファイルにPHPソースを埋め込む方法はあるのでしょうか? あるようでしたらご教授ください。 よろしくお願いします。

    • ベストアンサー
    • PHP
  • Smartyのエラーが2つずつ出ます

    PHP5+Smartyでサイトを作っています。 「$smarty->display("hoge.tpl");」としてテンプレートファイルを呼び出します。 そのテンプレートファイル「hoge.tpl」が存在しない時に、以下のエラー文が必ず2つ表示されます。 Warning: Smarty error: unable to read resource: "hoge.tpl" in /root/.../smarty/Smarty.class.php on line 1092 一度しか呼び出していないのにエラーが2つ表示されるので、コードの記述ミスかと考えたのですがわかりませんでした。 テンプレートファイルがある場合は、テンプレートが二度呼び出されることはありません。 エラー文にある1092行目からコードを追って見たのですがわかりませんでした。 どうすればエラー表示を1つにできるのでしょうか? 宜しくお願いします。

    • 締切済み
    • PHP
  • Movable Type のテンプレート内へPHPの記述するとエラーがでてしまします

    Movable Type(以下MT)をカスタマイズしています。 MTをPHP化してテンプレートにPHPを記述しているのですが、アーカイブテンプレートのブログ記事テンプレートにあるPHPの記述をすると、エラーが出てしまうのです。 PHPの記述とエラーの内容は以下の通りです。 ■PHPの記述 <?php <MTSetVar name="myName" value="北村"> <?php echo('<$MTGetVar name="myName"$>'); ?> ■エラーの内容 Smarty error: [in evaluated template line 9]: syntax error: unrecognized tag '/php' (Smarty_Compiler.class.php, line 580) 上記と同じ記述をアーカイブテンプレートのブログ記事リストテンプレートに記述した場合は、エラーは出ず、ちゃんと「北村」という文字が表示されるのですが、なぜかブログ記事テンプレートに記述すると上記のエラーが出てしまいます。 なお、制作環境は以下の通りです。 Movable Typeのバージョン:4.1 サーバーのPHPのバージョン:5.2 かれこれ半日試行錯誤しております。 原因に心あたりのあるかた、是非ご教授お願いいたします。さい。

  • Smartのカスタマイズでエラー

    いつもお世話になっております。 Smartyのカスタマイズを行いたく 設置でエラーになってしまいました。 public_htmlと同じ階層にSmartyフォルダを作成しました。 (下記のような構造になっています。) /public_html/ /Smart/configs/ /Smart/lib/ /Smart/templates/ /Smart/templates_c/ ファイルには下記のように記述しております。 /Smart/lib/smarty_setup.php ---------------------------------------- require_once 'Smarty.class.php'; class SmartySetup extends Smarty {  function SmartySetup() {   $this->template_dir = SMARTY_DIR . "templates";   $this->compile_dir = SMARTY_DIR . "templates_c";   $this->cache_dir = SMARTY_DIR . "cache";   $this->config_dir = SMARTY_DIR . "configs";   $this->left_delimiter = "<!--{";   $this->right_delimiter = "}-->";  } } ---------------------------------------- /public_html/smarty.php ---------------------------------------- require_once("../../Smarty/libs/smarty_setup.php"); $smarty = new Smarty(); $smarty->display("smarty.tpl"); ---------------------------------------- 実行すると、下記のようなエラーが表示されてしまいます。 Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'smarty.tpl'' in C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php:163 Stack trace: #0 C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php(541): Smarty_Internal_Template->isExisting(true) #1 C:\*****\Smarty\libs\Smarty.class.php(337): Smarty_Internal_Template->getRenderedTemplate() #2 C:\*****\Smarty\libs\Smarty.class.php(381): Smarty->fetch('smarty.tp...', NULL, NULL, NULL, true) #3 C:\*****\smarty.php(26): Smarty->display('smarty.tp...') #4 {main} thrown in C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php on line 163 どう対処すればいいでしょうか。 よろしくご教示お願いいたします。

    • ベストアンサー
    • PHP
  • ロリポップでSmartyのtpl読み込みエラー

    下記のコードを実行すると、  Smarty error: unable to read resource: "template1.tpl"  というエラーが出てしまいます。 $smarty->template_dirで指定したディレクトリ名の中に  "template1.tpl"というファイルは配置してあります。  原因などわかればおしえていただけないでしょうか。 index.php <?php require_once("Smarty.class.php"); $smarty = new Smarty; $smarty->template_dir = './templates/'; $smarty->compile_dir = './templates_c/'; $smarty->config_dir = './configs/'; $smarty->cache_dir = './cache/'; $smarty->display("template1.tpl"); ?> 【サーバ】  ロリポップです。 【その他】 index.phpをホームディレクトリ配下におくとエラーは消えます。 【ディレクトリ構成】 modules/index.php と templates/template1.tpl をがあり、 index.php から template1.tpl を読み込もうとしています。  ・modules →index.php ・templates →template1.tpl

    • ベストアンサー
    • PHP
  • Smartyエラーについて

    いつもお世話になっております。 Smartyのエラーが解決できなくて困っています。 お手数ですが、後教授願えないでしょうか。 使用環境:Ubuntu Eclipse [エラー] Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list.tpl'' in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php:163 Stack trace: #0 /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php(550): Smarty_Internal_Template->isExisting(true) #1 /home/mobapendev/public_html/Smarty/Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #2 /home/mobapendev/public_html/Smarty/Smarty.class.php(382): Smarty->fetch('list.tpl', NULL, NULL, NULL, true) #3 /home/mobapendev/public_html/mobapen/list.php(20): Smarty->display('list.tpl') #4 {main} thrown in /home/mobapendev/public_html/Smarty/sysplugins/smarty_internal_template.php on line 163 ディレクトリ構成 Smarty/Smarty.class.php Project/list.php Project/php/common.php project/smarty/templates/list.tpl project/smarty/templates_c project/smarty/cache project/smarty/configs となっており、 common.phpにて、 $dir = getcwd(); $smarty->template_dir=$dir .'/smarty/templates'; $smarty->compile_dir=$dir .'/smarty/templates_c'; $smarty->config_dir=$dir .'/smarty/configs'; $smarty->cache_dir =$dir .'/smarty/cache'; list.phpにて require_onceで取り込みまいしたが、 $smarty->display("list.tpl"); ディレクトリは間違っていないとは思っているのですが、 どこでload出来てていなか分からず、攻め上げいている状況です。 以上、宜しくお願い致します。

    • ベストアンサー
    • PHP
  • bindValueエラー

    Fatal error: Call to a member function bindValue() on a non-object in /home/アカウント名/www/index.php on line 487 というエラーが出てしまいました。 PHPバージョンはPHP 5.2.8です。 487行目前後のスクリプトは以下です。 if (!$smarty->is_cached(TEMPLATE_ARTICLE) or $page) { //表示記事番号取得 $stmt = $pdo->prepare('SELECT no FROM ' . DATABASE_TABLE_ARTICLE . ' WHERE stat = 1 ORDER BY date DESC LIMIT :start, :limit'); $stmt->bindValue(':start', intval($configs['_blog']['page_size']) * $page, PDO::PARAM_INT); $stmt->bindValue(':limit', intval($configs['_blog']['page_size']), PDO::PARAM_INT); $flag = $stmt->execute(); if (!$flag) { db_error($stmt->errorInfo()); } DBはsqliteを使っています。 バインドができていないというエラーですが、どのような解決法があるでしょうか?よろしくお願いします。

    • 締切済み
    • PHP
  • Smarty コンバートエラー??

    はじめまして。 PHP初心者です。 テンプレートにオブジェクト配列を渡して、表示させたいのですが、 テンプレートをコンパイルする際にエラーがでてしまいます。 呼び出し元のtest.phpに”echo $objArray[0] -> get_id();”と書くと正常に表示されるのでテンプレートと問題と思うのですが、原因が解らずこまっております。。。 ご指導お願い致します。 ■環境 OS:Fedora 4 php-5.2.0 Smarty-2.6.13 ■ブラウザに表示されるエラー Catchable fatal error: Object of class User could not be converted to string in /home/dev/board/templates_c/%%6D^6D7^6D7C5625%%test.tpl.php on line 3 ■テンプレート(test.tpl) {$users[0] -> get_id()} ■テンプレートの呼び出し元(test.php) require_once("DB.php"); require_once("Smarty/libs/Smarty.class.php"); $o_smarty = new Smarty(); $o_smarty -> template_dir = "../templates"; $o_smarty -> compile_dir = "../templates_c"; $o_smarty -> debugging = TRUE; $db = DB::connect("mysql://*********************"); $objArray = User::getUserInfos($db); echo $objArray[0] -> get_id(); $o_smarty -> assign("users",$objArray); $o_smarty -> display("test.tpl"); class User { private $_id; public function get_id(){return $this -> _id;} public function set_id($_id){$this -> _id = $_id;} public static function getUserInfos($db){ ・・(中略)・・ } return $aryUsr; } }

    • ベストアンサー
    • PHP
  • OpenPNE(2.x)に携帯版Adsense

    OpenPNE(2.x)に携帯版Google Adsenseを導入する方法 inc_ktai_header.tplに({php})adsense_mobile.php({/php})というようにincludeしたら、変数を汚染してセッションを狂わせるのかページ遷移ごとにログインを必要とするようになってしまいました。 動作をおかしくせず導入する方法を教えてください。

    • ベストアンサー
    • PHP
  • ライブドアのブログにGoogleアドセンス

    ライブドアのブログの記事に、Googleのアドセンス(AdSense)広告を載せたいのですが、載せる場所を一定にしたいと思います。 トップページの、最初の投稿の文章の下にだけ表示させることはできるでしょうか。 その場合、どこにGoogleから提供されたHTMLをはりつけておけばよいでしょうか。

専門家に質問してみよう