php,smarty,smarty3Related issues-Collection of common programming errors
Alan Moore
php json utf-8 character-encoding
I use JSON to encode an array, and I get a string like this:{“name”:”\u00fe\u00fd\u00f0\u00f6\u00e7″}Now I need to convert this to ISO-8859-9. I tried the following but it fails:header(‘Content-type: application/json; charset=ISO-8859-9’); $json = json_encode($response); $json = utf8_decode($json); $json = mb_convert_encoding($json, “ISO-8859-9”, “auto”); echo $json;It doesnt seem to work. What am I missing?Thank you for your time.
Mr Coder
php facebook-fql where
I am trying to use two WHERE clauses in one fql query SELECT uid, pic, pic_square, name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND WHERE strstr(‘ab’,name)but getting errorParser error: unexpected ‘WHERE’ at position
Doon
php datetime
I’ve used DateTime::createFromFormat() to parse string into date before, but today I found a problem and I get null from this call.echo $date_string; $test = DateTime::createFromFormat(‘M d Y, H:i:s T’, trim($date_string)); echo $test->format(‘Y-m-d H:i:s’);Output:Oct 16 2013, 15:45:02 CEST( ! ) Fatal error: Call to a member function format() on a non-object in (…) on line 51Where line 51 is the last line where I call format().So, am I missing something? Thanks in advance!The output of Date
Mostafa Talebi
javascript php jquery
We write a custom function’s arguments in PHP like this:function something ($arg = “”) {// then do something }How this should be done in jquery?this seems not to work:function jq_something ($arg = “”) {}
GolezTrol
php
define(“QUERY”,”INSERT INTO rft_media_invention . ” ” (dbInventionFileType, dbStaffId, dbInventionFileName, dbInventionFileContent)” . “VALUES (?, ?, ?, ?)”);Its always giving me this error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in p3t\phpappfolder\public_php\cw\UC213.php on line 20anyone knows if my query is fully correct?
Nanne
php mysql if-statement while-loop
I have the following php code:<?phpif (!isset($_REQUEST[‘search’])){while(($write=mysql_fetch_array($gamesearched)) != null){echo “Found!”;}else{echo “No results”;}} ?>And it’s giving me an error:Parse error: syntax error, unexpected ‘else’ (T_ELSE) inC:\php\www\Gameplay\backgame.php on line 41
teresko
php php-parse-error
When I do:class MyClass {public $copy = file_get_contents(‘somefile.mdown’); }I get:PHP Parse error: syntax error, unexpected ‘(‘, expecting ‘,’ or ‘;’ \ in /file.php on line 25I’m new to classes in PHP, but not to OOP.I can, of course, just do file_get_contents outside of the class and all is well. What’s up with this?
Hugo
php parsing
I get the following error;Parse error: syntax error, unexpected T_STRING in D:\XAMPP\xampp\htdocs\site\register.php on line 95Line 95 is;if (strstr($email, “@”) && strstr($email, “.”) strlen($email) >=6))Please help, I don’t know what’s wrong :/ It all looks fine to me. Thanks In Advance!
user327046
php zend-framework cron set-include-path
I wrote a command line utility using Zend Framework to do some nightly reporting. It uses a ton of the same functionality the accompanying site. It works great when I run it by hand, but when I run it on cron I have include path issues. Seems like it should be easily fixed with set_include_path, but maybe I’m missing something?My directory structure looks like this:/var/www/clientname/applicationGlobals.phpcommandlinecommandline_bootstrap.php public_htmlpublic_bootstrap.php libraryZ
user356556
php html parsing
I was just helped with this question but I can’t get it to move to the next block of HTML.$html = file_get_html(‘http://music.banadir24.com/singer/aasha_abdoo/247.html’);$urls = $html->find(‘table[width=100%] table tr’);foreach($urls as $url){$song_name = $url->children(2)->plaintext;$url = $url->children(6)->children(0)->href; }It returns the list of the names of the first album (Deesco) but it does not continue to the next album (The Best Of Aasha)? It just gives me this er
Paul Rusu
php smarty whmcs
I have added the function.bnr_exchange.php to the includes/smarty/plugins directory. It contains smarty_function_bnr_exchange which returns a string.I also modified invoicepdf.tpl $pdf->Cell(0,6,{bnr_exchange} . ”,0,1,’L’,’1′);which gives error: unexpected { I tried with “{bnr_exchange}” but then it writes the text {bnr_exchange}If i simply write {bnr_exchange} in the template it says unexpected } in that line. So it doesn’t recognize the plugin “bnr_exchange”. My question is how do I tell w
Claude Grecea
php pdo smarty
I am having a problem with Smarty passing a PDO Object to Smarty it just doesn’t like =>. Is there a trick to get around this problem?Here is he error:{assign var=’brgdatas’ value=”{$brgObj->fetchOneBrg(array(‘id’=>{$ststres[ststval].to_id}’))}”}” – Unexpected “=>”, expected one of: “”,”” , “)Here is the code I am working with:{section name=ststval loop=$ststres}{if $ststres[ststval].type == 2}{assign var=’brgdatas’ value=”{$brgObj->fetchOneBrg(array(‘id’=>{$ststres[ststval].to
Jerielle
javascript jquery smarty
Hello guys I have a problem in getting textboxes inputs in my jquery using ID. Ok here’s my code.<script type=”text/javascript”>var globalBase_Url = “{$base_url}”; //OK NO ERROR var name = “”;var desc = “”;{literal}$(document).ready(function(){$(‘#add_cat’).on(‘click’,function(){$(‘#add_category’).show(‘slide’);});$(‘#submit’).on(‘click’,function(){jquery.ajax({ var name = $(‘#category_name’).val(); //this is the errorvar desc = $(‘#description’).val(); // this is the error});});});{/li
NemoPS
jquery ajax smarty
I need to output a couple of lines of escaped html using ajax, with the object being generated by smarty. However, I keep getting unexpected token even if I used both nl2br and |regex_replace:’/[\r\n]/’ : ‘<br/>’.Here is the troublesome code:”value”: “<div class="ps-header-links"><br/> <br/> <ul><br/> <li><a href="http://prestashop.com" ti
j0k
javascript smarty prestashop
I’m developing a Prestashop website, and I’m getting a “SyntaxError: unterminated string literal” javascript error. The problem is when I get an address, this works nice:,”address1″:”Pza libertad” ,”address2″:”4º 3ª” ,”postcode”:”08905″The problem comes here:,”address1″:”Plaza libertad 3″,”address2″:” 4º3ª”,”postcode”:”08905″This code is generated like this:{foreach from=$type.formated_fields_values key=pattern_name item=field_name name=inv_loop} {if !$smarty.
Bas
php variables smarty
I have the following code and the output.If i print_r, normal echo {} of foreach, i am getting the number 1?What do i do wrong?!Controller:if( $checkOrderNumber == ” || $checkOrderNumber == NULL ){$var = ‘<a class=”tool-link” href=”url.php?dispatch=orders.details&order_id=’. $_REQUEST[‘order_id’] .’&sendsurvey=yes”>Send FBC invitation</a>’; }else{$var = ‘<a href=”#”>FBC has been sent</a>’; }Registry::get(‘view’)->assign(‘var’, $var);Smarty TPL:{assign var=”var
dazfx
php function smarty prestashop
Is a function that is called in product-list.php.{mycat id_product_my=$product.id_product}In this form, write a line above, the variable($product.id_product) is not passed to function:{$product.id_product}returns right result as id.{mycat id_product_my=15}returns right result as categories of product with id(15).What’s wrong?——————————————–php funct:function smarty_compiler_mycat($params, &$smarty) {$id_product_my = $params[‘id_product_my’];$ret = “”;if ($row = D
Messer
php smarty
I have a project that uses Smarty template engine (2.6). Point is I can’t have it save files locally as it would mean saving to the repository. Same with cache.My question is – how should I implement compiling templates to, for example, memcache?I was playing with stream wrapper for it but maybe someone has a better solution?
rag
php smarty
WARNING [2] include(somepath/templates_c/%%B0^B01^B019F522%%login.htm.php) [function.include]: failed to open stream: No such file or directory on Line No 1871 in somepath/Smarty.class.php Error!: An internal error occurred during runtime.Any body please tell me why this error is occuring..
Dainis Abols
php exception-handling smarty smarty3
I have block try – catch and i want assign error to the template to $error. I tried:catch (Exception $e) {$smarty->assign(“error”, ‘Error! Details: ‘.$e->getMessage()); }Also tried:catch (Exception $e) {$error = $e->getMessage()); } $smarty->assign(“error”, $error);But when there is no error, smarty requires this variable and all crashes. Is there any way to deal with it without using if? Or may be i am doing wrong from the begining?
Syntax Error
upgrade smarty3 cmsmadesimple
I’m new to CMSMS and taking an older installation through a painful upgrade path to get it to the current version. One of the major changes involves using Smarty 3 for it’s templating engine. This change has broken a couple of the existing templates.The related CMSMS module is called “Product and Inventory Manager” which looks like it’s part of “Calguys Module Extensions”Here’s the error message I’m getting:Syntax Error in template “module_db_tpl:ProductsWithLocation;summary_default” on line 26
Dainis Abols
php exception-handling smarty smarty3
I have block try – catch and i want assign error to the template to $error. I tried:catch (Exception $e) {$smarty->assign(“error”, ‘Error! Details: ‘.$e->getMessage()); }Also tried:catch (Exception $e) {$error = $e->getMessage()); } $smarty->assign(“error”, $error);But when there is no error, smarty requires this variable and all crashes. Is there any way to deal with it without using if? Or may be i am doing wrong from the begining?
Athanatos
php smarty smarty3
My ajax php located in maindirexample/actions is calling a tpl file one folder up in maindirexample/templatesfetch(‘../templates/popupMyItems.tpl’); However this throws an error <br /> <b>Fatal error</b>: Uncaught exception ‘SmartyException’ with message ‘Unable to load template file ‘list-myItems.tpl’ in ‘../templates/popupMyItems.tpl’popupMyitems.tpl seems to be called ok, however list-myItems.tpl fails (this is included in popupMyitems.tpl) ..{foreachfrom=$uniquecategories i
Vipan Kumar
php smarty3 server-configuration
I have created project in smarty and now i am trying to host it on pagodabox.com. I have created application on pagodabox.com and uploaded all code on to this application but problem is this now i am unable to configure cache and compiler directory in pagodabox.com that’s why it output fetal error because cache and compiler directory is read only mode. I have try Boxfile to resolve this issue but failing to solve. I am not aware how i can make these directory writable. please help me. this is ur
fl3x7
php codeigniter smarty codeigniter-2 smarty3
Im currently using codeigniter 2 with ci-Smarty. Just been trying to add a smarty output filter but not having much luck. Its as if the function cannot be found or something?I am using a plugin as the output filter function and have the following code:LOCATION: /libraries/Smarty.php// Set email output filter $this->loadFilter(‘output’, ‘protect_email’);LOCATION: /third_party/Smarty/plugins/function.protect_email.phpfunction smarty_function_protect_email($tpl_output, Smarty_Internal_Template $
Hailwood
php javascript escaping smarty3
I am using the below code with smarty V3<script>$(function() {jwplayer(“video-player-{$v->id}”).setup( {file: “/webfiles/competitions/movies/{$v->file}”,skin: “/assets/jwplayer/skins/simplicity/simplicity.zip”,width: 446,height: 353,stretching: “fill”,flashplayer: “/assets/jwplayer/player.swf”} );} ); </script>The manual states:Note{literal}{/literal} tags are normally not necessary, as Smartyignores delimiters that are surrounded by whitespace. Be sure yourjavascript and CSS c
JochenJung
include smarty block smarty3
I have some templates written with Smarty 3:A layout page An index page An include pagelayout.tpl:{block “css”}{/block} {block “js”}{/block} {block “content”}{/block}index.tpl:{extends “layout.tpl”} {block “content”} content text {include “include.tpl”} {/block}include.tpl{block “js” append} include some extra js files for this included content {/block} include textBut I got a compiler exception:Fatal error: Uncaught exception ‘SmartyCompilerException’ with message ‘Syntax Error in template inc
lukaswilkeer
smarty3
What’s this? Does any error in the configuration file? Following is the full error.Fatal error: Uncaught exception ‘SmartyException’ with message ‘Unableto load template file ‘index.tpl” in/var/www/stoke/libs/sysplugins/smarty_internal_templatebase.php:127Stack trace: #0/var/www/stoke/libs/sysplugins/smarty_internal_templatebase.php(374):Smarty_Internal_TemplateBase->fetch(‘index.tpl’, NULL, NULL, NULL,true) #1 /var/www/stoke/index.php(41):Smarty_Internal_TemplateBase->display(‘index.tpl’) #2 {
Rajat
php smarty smarty3
My file structure:–header.php –smarty–templates– x.tpl–cache–configs–templates_c –articles– testPage.phpCode in header.php$smarty = new Smarty();$smarty->setTemplateDir(‘smarty/templates’); $smarty->setCompileDir(‘smarty/templates_c’); $smarty->setCacheDir(‘smarty/cache’); $smarty->setConfigDir(‘smarty/configs’);Code in testPage.php<?phpinclude(‘../header.php’);$smarty->display(‘x.tpl’); ?>I am hitting this error:PHP Fatal error: Uncaught exception ‘SmartyException
user861587
php smarty echo combine smarty3
Why doesn’t this work in Smarty?{my_function($test.’a1′)}It’s showing following error: Fatal error: Uncaught exception ‘SmartyCompilerException’ with message ‘Syntax Error in template “test.tpl” on line 1 “{my_function($test.’a1’)}” Unexpected “‘a1′”, expected one of: “{” , “$” , “identifier” , INTEGER’ in…
Web site is in building