Jumi in joomla 1.7 article cant use

Discuss the development and implementation of Joomla! bots/Plugins here.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
johnsontoh
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Oct 30, 2011 1:20 pm

Jumi in joomla 1.7 article cant use

Post by johnsontoh » Sun Oct 30, 2011 1:24 pm

i have included like.php into a article like this {jumi [like.php]} into joomla. and the contents of like.php is

Code: Select all

<html>
   <head>
      <title>How to create a like/unlike button using jQuery and PHP</title>
       
   <script src="http://code.jquery.com/jquery-1.3.2.min.js"></script>
      <script>
         function doAction(postid,type){
            $.post('doAjax.php', {postid:postid, type:type}, function(data){
               if(isNaN(parseFloat(data))){
                  alert(data);
               }else{
                  $('#'+postid+'_'+type+'s').text(data);
               }
            });
         }
      </script>
   </head>
   <body>
      <?php
      
         include('db.php'); // including database connection.
         
         $postid = 1; // default post id
         $data = mysql_fetch_object(mysql_query('SELECT `like`,`unlike` FROM posts WHERE id="'.$postid.'"'));
      
      ?>
      <a href="javascript:;" onclick="doAction('<?php echo $postid;?>','like');">Like (<span id="<?php echo $postid;?>_likes"><?php echo $data->like;?></span>)</a>
      <a href="javascript:;" onclick="doAction('<?php echo $postid;?>','unlike');">Unlike (<span id="<?php echo $postid;?>_unlikes"><?php echo $data->unlike;?></span>)</a>
   </body>
</html>
db.php

Code: Select all

<?php

   $host = 'localhost';
   $user = 'root';
   $pass = '';
   $db = 'like';
   
   $conn = mysql_connect($host, $user, $pass) or die(mysql_error());
   mysql_select_db($db, $conn) or die(mysql_error());
   
?>
ajax.php

Code: Select all

<?php

   include('db.php');
   
   if($_POST['postid'] != '' && $_POST['type'] != ''){
      
      $alreadyExist = mysql_num_rows(mysql_query(' SELECT id FROM voted WHERE postid="'.(int)$_POST['postid'].'" AND ip="'.$_SERVER['REMOTE_ADDR'].'"'));
      
      if($alreadyExist==0){
         if($_POST['type']=='like'){
            mysql_query(' UPDATE posts SET `like`=`like`+1 WHERE id="'.(int)$_POST['postid'].'"');
            $num = mysql_fetch_row(mysql_query(' SELECT `like` FROM posts WHERE id="'.(int)$_POST['postid'].'" LIMIT 1'));
         }elseif($_POST['type']=='unlike'){
            mysql_query(' UPDATE posts SET `unlike`=`unlike`+1 WHERE id="'.(int)$_POST['postid'].'"');
            $num = mysql_fetch_row(mysql_query(' SELECT `unlike` FROM posts WHERE id="'.(int)$_POST['postid'].'" LIMIT 1'));
         }
         echo $num[0];
         mysql_query(' INSERT INTO voted (`postid`,`ip`) VALUES ("'.(int)$_POST['postid'].'","'.$_SERVER['REMOTE_ADDR'].'")');
         
      }else{
         echo 'You already voted this.';
      }
      
   }

?>
codes taken from http://www.mlabs.info/create-likeunlike ... query-php/
but in my joomla page, it only previews the like and unlike button, i am unable to press it.
may i ask why ?

johnsontoh
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Oct 30, 2011 1:20 pm

Re: Jumi in joomla 1.7 article cant use

Post by johnsontoh » Mon Oct 31, 2011 6:22 am

anyone?

johnsontoh
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Oct 30, 2011 1:20 pm

Re: Jumi in joomla 1.7 article cant use

Post by johnsontoh » Tue Nov 01, 2011 5:37 am

Could it be a javascript conflict with some other script in joomla site?


Locked

Return to “Plugins/Mambots”