Click here to Skip to main content
16,020,811 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: post data missing after php parses raw post to post variable Pin
Marc Firth24-Nov-09 22:46
Marc Firth24-Nov-09 22:46 
GeneralRe: post data missing after php parses raw post to post variable Pin
cjoki25-Nov-09 8:43
cjoki25-Nov-09 8:43 
GeneralRe: post data missing after php parses raw post to post variable Pin
Marc Firth25-Nov-09 22:20
Marc Firth25-Nov-09 22:20 
GeneralRe: post data missing after php parses raw post to post variable Pin
cjoki27-Nov-09 10:37
cjoki27-Nov-09 10:37 
QuestionProblem with Visual Cpp compiler Pin
Game-point23-Nov-09 18:10
Game-point23-Nov-09 18:10 
AnswerRe: Problem with Visual Cpp compiler Pin
Richard MacCutchan1-Dec-09 2:29
mveRichard MacCutchan1-Dec-09 2:29 
AnswerRe: Problem with Visual Cpp compiler Pin
LloydA11114-Jan-10 8:42
LloydA11114-Jan-10 8:42 
QuestionHelp with assigning variables to smarty template engine (php). Pin
djkee23-Nov-09 10:20
djkee23-Nov-09 10:20 
Hello everyone, i have a big problem with this $smarty->assign Frown | :(

I found a nice script that would add smileys to my website in users comments but since the comments are coming from the database i am not sure how to make smarty replace the smiley characters with images.

Here is the script i am trying to get working:
/*-----------------------------------------------------------------------------
    @Function    :  addSmilies()
    @Params      :  1. $text: Text to render.
    @Description :  This functions replaces the basic smiley equavalent codes
                    into smilies and returns back the html code after adding smilies
                    images
    @Returns     :  Returns the converted html string.
 
    NOTE         :  Make sure you provide the image path correctly. Use absolute or relative
                    paths, whatever suits to your script.
    -----------------------------------------------------------------------------*/
    function addSmilies($text) {
        //codes and its relevant smiley image path
        $codesToConvert = array(
                ':)'    =>  '<img src="http://blog.sachinkraj.com/images/smilies/smile.png" alt="smile" />',
                ':-)'   =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/smile.png" alt="smile" />',
                ':D'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/laugh.png" alt="laugh" />',
                ':d'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/laugh.png" alt="laugh" />',
                ';)'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/wink.png" alt="wink" />',
                ':P'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/tounge.png" alt="tounge" />',
                ':-P'   =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/tounge.png" alt="tounge" />',
                ':-p'   =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/tounge.png" alt="tounge" />',
                ':p'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/tounge.png" alt="tounge" />',
                ':('    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/sad.png" alt="sad face" />',
                ':o'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/shock.png" alt="shock" />',
                ':O'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/shock.png" alt="shock" />',
                ':0'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/shock.png" alt="shock" />',
                ':|'    =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/straight.png" alt="straight face" />',
                ':-|'   =&gt;  '<img src="http://blog.sachinkraj.com/images/smilies/straight.png" alt="straight face" />'
               );
        //Replaces smilies codes / add smilies images: IMG html tags and return rendered text
        return (strtr($text, $codesToConvert));
 
    }//END addSmilies()



Here is how the above code works:
$comment = 'This is the example comment with few smilies code we use normally. Like these: :) :D :P :p :O :-| . Its funny and cute. Isnt it? :)';
 
    //prints text as it is, adding just to make it visually good looking
    echo '<strong>Text with smiley codes:</strong>' . $comment ;
 
    //parse text and convert smilies codes into images, lets see
    echo '<strong>Text with smiley images:</strong>' . addSmilies($comment);


Here is part of the code that assigns the smarty variable which are later used to display the reviews (comments).
$averageRating = am_getrating($got_gameid); // 5 star rating system
$reviews = am_queries($db, "SELECT * FROM AMCMS_reviews WHERE gameid=$got_gameid AND approved=1;");
$countreviews = am_countrecords($db, "SELECT * FROM AMCMS_reviews WHERE gameid=$got_gameid AND approved=1;");


// Create template variables:
	$smarty->assign('sitetitle',$sitetitle);
	$smarty->assign('metadesc',$metadesc);
	$smarty->assign('metakeywords',$metakeywords);
	$smarty->assign('insertGame',$insertGame);
	$smarty->assign('headload',$headload);
	$smarty->assign('bodyload',$bodyload);
	$smarty->assign('gameAvgRating', $averageRating);	
	$smarty->assign('echoComment', $echoComment);
	$smarty->assign('gameId', $gameres[0][0]);
	$smarty->assign('gameName', $gameres[0][1]);
	$smarty->assign('gameDescription', $gameres[0][2]);		
	$smarty->assign('gameOriginalWidth', $originalwidth);
	$smarty->assign('gameOriginalHeight', $originalheight);	
	$smarty->assign('gameFilename', $gameres[0][6]);
	$smarty->assign('gameCategory', $gameres[0][7]);
	$smarty->assign('gamePlayCount', $gameres[0][8]);
	$smarty->assign('gameExtension', strtolower($gameres[0][10]));
	$smarty->assign('gameReviews', $reviews);
	$smarty->assign('gameCountReviews', $countreviews);
	$smarty->assign('gameHighScoreList', am_highscore($gameres[0][0], 'high', 10, 'list', false));
	$smarty->assign('gameRecommendedList', am_listnewgames('list', 8, $gameres[0][7], false));
	$smarty->assign('gameCode', html_entity_decode($gameres[0][15])); // Added in 2.800.



Here is the code that shows the comments
        {$echoComment}
</div></div>
<p />
<div class="reviews">
        <h2 class="title"><center>{$gameCountReviews} reviews for {$gameName}</center></h2>

    <center>
    {foreach from=$gameReviews item=individualReview}
        <div class="individualreview">Review by <i>{$individualReview.2}</i><p />
            <div class="reviewtext">{$individualReview.3}</div>
        </div><br /><p />
    {/foreach}




I have been trying to fix this all day and it just wont show the comments, i tried to assign the script to a smarty variable but then how would i use it as the script says ? addSmilies($comment);

I tried few other scripts and tried to include it in the .tpl file but that didnt work, i tried all kinds of ways to make the addSmilies({$individualReview.3}) work by adding what not in there but it just wont work.
For the last few hours i have been looking in the smarty manual but i cant see anything even close to this Frown | :(
I am sorry for all the code and i am really new to php and smarty so i really need some help.

Please somebody help me Cry | :(( Cry | :((
AnswerRe: Help with assigning variables to smarty template engine (php). Pin
fly90423-Nov-09 10:53
fly90423-Nov-09 10:53 
GeneralRe: Help with assigning variables to smarty template engine (php). Pin
djkee23-Nov-09 13:42
djkee23-Nov-09 13:42 
GeneralRe: Help with assigning variables to smarty template engine (php). Pin
fly90424-Nov-09 2:30
fly90424-Nov-09 2:30 
GeneralRe: Help with assigning variables to smarty template engine (php). Pin
djkee24-Nov-09 8:30
djkee24-Nov-09 8:30 
QuestionPERL Craps game Pin
Rhodge0923-Nov-09 9:30
Rhodge0923-Nov-09 9:30 
AnswerRe: PERL Craps game Pin
Rhodge0923-Nov-09 9:51
Rhodge0923-Nov-09 9:51 
Questionextract numeric values from string Pin
shaina223120-Nov-09 2:42
shaina223120-Nov-09 2:42 
AnswerRe: extract numeric values from string Pin
cjoki20-Nov-09 6:37
cjoki20-Nov-09 6:37 
AnswerRe: extract numeric values from string Pin
fly90420-Nov-09 17:14
fly90420-Nov-09 17:14 
AnswerRe: extract numeric values from string Pin
Marc Firth23-Nov-09 22:21
Marc Firth23-Nov-09 22:21 
GeneralRe: extract numeric values from string Pin
fly90424-Nov-09 2:32
fly90424-Nov-09 2:32 
GeneralRe: extract numeric values from string Pin
Marc Firth24-Nov-09 2:45
Marc Firth24-Nov-09 2:45 
QuestionWeb framework [modified] Pin
rastaVnuce18-Nov-09 14:39
rastaVnuce18-Nov-09 14:39 
AnswerRe: Web framework Pin
Michael Hansen23-Nov-09 12:37
Michael Hansen23-Nov-09 12:37 
GeneralRe: Web framework Pin
rastaVnuce23-Nov-09 12:40
rastaVnuce23-Nov-09 12:40 
AnswerRe: Web framework Pin
Chris Austin5-Dec-09 8:24
Chris Austin5-Dec-09 8:24 
GeneralRe: Web framework Pin
rastaVnuce8-Dec-09 13:52
rastaVnuce8-Dec-09 13:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.