Hi, i have was make small social network website and now i need to use RESTful API for hybrid application.
Social network website i make in php, mysql.
How to make API now?
Do you have some tutorial for API that integrate in existing website?
Thanks!

Hi I have problem to get data when insert with ajax. I have ajax.js file and here is this code:

$('#text-content').keypress(function(e){ if(e.which == 13) { if($('input#enter-click').prop('checked', true)) { $('#live-send').click(); e.preventDefault(); } } }); $('#live-send').click(function(){ var message = $.trim( $('#text-content').val() ); if($('#text-content').val()!="") { $.ajax({ type: 'POST', dataType: "json", url: './includes/conversation.php', data: { message: message }, cache: false, success: function(data) { $('.commentArea').load( 'Messages.php.'); $('.bubbledRight').val(""); } }); // setInterval(function(){ // $('.commentArea').load( 'Messages.php.'); // },1000); return false; } else { //notify the user they need to enter data alert("Please write messages!"); } }); $('.max-height').scrollTop($('.max-height')[0].scrollHeight); //show messages on bottom In index page I have <div class="commentArea"></div>

for show conversation this is query for select:

<?php $conversation_ID = 1; $sql = "SELECT * FROM conversations_messages WHERE conversation_ID='{$conversation_ID}' ORDER BY time ASC"; $query = $connection->prepare($sql); $query->execute(); while($r = $query->fetch(PDO::FETCH_OBJ)) { $data = ""; // startting div tag if ( $user_ID == $r->sender_ID ) { $data .= '<div class="bubbledRight">'; } else { $data .= '<div class="bubbledLeft">'; } // image tag (later to add) $data .= '<img class="img-responsive" alt="" src="images/profileimage.jpg">'; // message content $data .= $r->message; // time sent (latter to add) $data .= '<span class="label label-default">21.Aug</span>'; // ending div tag $data .= '</div>'; // display message echo $data; } ?>

I insert data in database corectly but if want to see in index I must refresh page. How to fix this problem? Thanks!

Hi I have problem to get data when insert with ajax. I have ajax.js file and here is this code: $('#text-content').keypress(function(e){ if(e.which == 13) { if($('input#enter-click').prop('checked', true)) { $('#live-send').click(); e.preventDefault(); } } }); $('#live-send').click(function(){ var message = $.trim( $('#text-content').val() ); if($('#text-content').val()!="") { $.ajax({ type: 'POST', dataType: "json", url: './includes/conversation.php', data: { message: message }, cache: false, success: function(data) { $('.commentArea').load( 'Messages.php.'); $('.bubbledRight').val(""); } }); // setInterval(function(){ // $('.commentArea').load( 'Messages.php.'); // },1000); return false; } else { //notify the user they need to enter data alert("Please write messages!"); } }); $('.max-height').scrollTop($('.max-height')[0].scrollHeight); //show messages on bottom In index page I have <div class="commentArea"></div> for show conversation this is query for select: <?php $conversation_ID = 1; $sql = "SELECT * FROM conversations_messages WHERE conversation_ID='{$conversation_ID}' ORDER BY time ASC"; $query = $connection->prepare($sql); $query->execute(); while($r = $query->fetch(PDO::FETCH_OBJ)) { $data = ""; // startting div tag if ( $user_ID == $r->sender_ID ) { $data .= '<div class="bubbledRight">'; } else { $data .= '<div class="bubbledLeft">'; } // image tag (later to add) $data .= '<img class="img-responsive" alt="" src="images/profileimage.jpg">'; // message content $data .= $r->message; // time sent (latter to add) $data .= '<span class="label label-default">21.Aug</span>'; // ending div tag $data .= '</div>'; // display message echo $data; } ?> I insert data in database corectly but if want to see in index I must refresh page. How to fix this problem? Thanks!

Hi i get all information what i need but i dont know how to get facebook profile image and save to file and in mysql save path. Here is my code for call fb api :

<?php session_start(); include_once("config.php"); // facebook id include_once("includes/functions.php"); //destroy facebook session if user clicks reset if(!$fbuser){ $fbuser = null; $loginUrl = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope'=>$fbPermissions)); echo '<a href="'.$loginUrl.'"><img src="images/fb_login.png"></a>'; }else{ $user_profile = $facebook->api('/me?fields=id,first_name,last_name,email,gender'); $user = new Users(); $user_data = $user->checkUser('facebook',$user_profile['id'],$user_profile['first_name'],$user_profile['last_name'],$user_profile['email'],$user_profile['gender']); if(!empty($user_data)){ $_SESSION['userdata'] = $user_data; header("Location:account.php"); }else{ die('Some problem occurred, please try again.'); } } ?>

How to make popup login and register from index.php to work and to parse data in mysql
I have:
Index.php, login.php, register.php
In index.php I have modal popup and I want to user can login and register from popup.
I try with ajax but not working.
Here is my code:
ajax.php:

  function validLogin(){
  var email=$('.email').val();
  var password=$('.password').val();
  $.ajax({
      type: "POST",
      url: "sign-in.inc",
     data: "name="+username+"&pwd="+password,

      success: function(html){

           if(html=='true'){
            alert ("Correct");

          }
          else{
              alert ("Wrong");

          }
}

  });
  }

and here is popup form :

      <div id="login">
        <form class="form login-form" name="login-popup" >

             <a class="btn-facebook" href="#"><span><i class="fa fa-facebook"></i>
</span><span>Login with Facebook</span></a>
              <a class="btn-google" href="#"><span><i class="fa fa-google-plus"></i>
</span><span>Login with Google</span></a>

          <p class="fieldset">
            <label class="image-replace email icon-log" for="signin-email">E-mail</label>
            <input class="full-width has-padding has-border email" id="signin-email" name="email-login" type="email" placeholder="E-mail" name="email" required>
            <span class="error_box"></span>
          </p>

          <p class="fieldset">
            <label class="image-replace password" for="signin-password">Password</label>

            <input class="full-width has-padding has-border password" id="signin-password"  type="password"  placeholder="Password"
            name="password" required>

            <a href="#0" class="hide-password">Show</a>
            <span class="error-message"></span>
          </p>

          <p class="fieldset">
            <input type="checkbox" id="remember-me" checked>
            <label for="remember-me">Remember me</label>
          </p>

          <p class="fieldset">
            <input class="full-width orange" id="login-submit" type="submit" name="submit" onclick="validLogin()" value="Login">
          </p>
        </form>

        <p class="form-bottom-message"><a href="#0">Forgot your password?</a></p>
        <!-- <a href="#0" class="close-form">Close</a> -->
      </div>

Please help me I try but I only get error and send this url:
http://website.com?email-login=proba%40gmail.com&password=vasgas85&submit=Login#0

Hello i have problem on mobile device to prevent on click to another image to hide first. This is for hover effect and work fine :

$("div.mitarbeiterfoto")
        .mouseenter(function() { 
                var id = $(this).attr("id");
                var idInfo = $(this).attr("id").substr(5);
                ($(this).find('img').css('display', 'none'));
                ($('#' + id + '_o').css('display', 'block'));
                showInfo(idInfo);
        })

        .mouseleave(function() {
                var id = $(this).attr("id");
                var idInfo = $(this).attr("id").substr(5);
                ($(this).find('img').css('display', 'block'));
                ($('#' + id + '_o').css('display', 'none'));
                hideInfo(idInfo);
        });

but for mobile i try in this way:

var clickOrTouch = (('ontouchend' in window)) ? 'touchend' : 'click';

            $('div.mitarbeiterfoto').on(clickOrTouch, function(e) {

                var id = $(this).attr("id");
                var idInfo = $(this).attr("id").substr(5);

                  ($(this).find('img').css('display', 'none'));
                ($('#' + id + '_o').css('display', 'block'));

                showInfo(idInfo);

        });

but only show on every click information not prevent to be hide when click on another image. How to do this? Thanks!

Overlapping the main badge.

$(".layout tr").click(function() {
        var url = "http://" + $(location).attr('host');
        url += "/pdfs/" + $(this).attr('data-href') + ".pdf";
        window.open(
          url,
          '_blank' // <- This is what makes it open in a new window.
        );          
    });

How to make in admin page to see in navigation Badge with number of post.
Autors make new post and administrator see like in this image example:
aebb9fd23d41b5677781d14c3d116dcd

Thanks!!!

How to share sigle post when click on button ex. fbshare, twitshare and show them in facebook.
Do you know some examples or tutorial?

How to when click on share button share on facebook post from website example:
my website url : blog.com/name_of_post
in my url show only title of post.
How to share from every post on facebook?

This is my code:

if(!isset($error)){

            try {

                $postSlug = slug($postTitle);

                //insert into database
                $stmt = $db->prepare('INSERT INTO blog_posts_seo (postTitle,postSlug,images,postDesc,postCont,postDate) VALUES (:postTitle, :postSlug, :images, :postDesc, :postCont, :postDate)') ;
                $stmt->execute(array(
                    ':postTitle' => $postTitle,
                    ':postSlug' => $postSlug,
                    ':images' => $images,
                    ':postDesc' => $postDesc,
                    ':postCont' => $postCont,
                    ':postDate' => date('Y-m-d H:i:s')
                ));
                $postID = $db->lastInsertId();

How to work?

How to upload images into database with pdo or only image name and image move into folder

How to insert image name in database and image store in folder image with move_uploaded_file usign PDO:

this is my query:

$stmt = $db->prepare('INSERT INTO blog_posts_seo (postTitle,postSlug,image,postDesc,postCont,postDate) VALUES (:postTitle, :postSlug, $filename, :postDesc, :postCont, :postDate)') ;
                $stmt->execute(array(
                    ':postTitle' => $postTitle,
                    ':postSlug' => $postSlug,
                    '$filename' => $image,
                    ':postDesc' => $postDesc,
                    ':postCont' => $postCont,
                    ':postDate' => date('Y-m-d H:i:s')
                ));

Oh i try but the same error :/
When put only 2 letter show mi cant find but when is more letter error.

<?php require('includes/config.php'); ?>

<?php 
     $keyword = $_GET['query'];
    // gets value sent over search form

    $min_length = 3;
    // you can set minimum length of the query if you want

    if(mb_strlen($keyword) >= $min_length){ 
     $stmt = $db->prepare("SELECT FROM blog_post_seo MATCH (postTitle, postDesc, postCont) AGAINST (:keyword)");
    $stmt->execute(array(':keyword'=>$keyword));
    while($res = $stmt->fetchAll(PDO::FETCH_ASSOC)){
        echo $row['postTitle'];
         echo $row['postDesc'];
          echo $row['postCont'];
    }

}
 else {
        echo 'Cant find! ';
    }
 ?>

I do like this but have errors:

<?php require('includes/config.php'); ?>

<?php 
 $query = $_GET['query'];
    // gets value sent over search form

    $min_length = 3;
    // you can set minimum length of the query if you want

    if(mb_strlen($query) >= $min_length){ 
     $stmt = $db->prepare("SELECT FROM blog_post_seo MATCH(postTitle,postDesc,postCont) AGAINST (:keyword)");
    $stmt->execute(array(':keyword'=>$keyword));
    while($row = $stmt->fetch()){
        echo $row['postTitle'];
    }

}
 ?>

error: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;

How to make searching for my blog with pdo?
I try like this:

<?php require('include/config.php');?>

<?php
    $query = $_GET['query'];
    // gets value sent over search form

    $min_length = 3;
    // you can set minimum length of the query if you want

    if(strlen($query) >= $min_length){ // if query length is more or equal minimum length then

        $query = htmlspecialchars($query);
        // changes characters used in html to their equivalents, for example: < to &gt;

        $query = mysql_real_escape_string($query);
        // makes sure nobody uses SQL injection

        $raw_results = mysql_query("SELECT * FROM articles
            WHERE (`title` LIKE '%".$query."%') OR (`text` LIKE '%".$query."%')") or die(mysql_error());

        // * means that it selects all fields, you can also write: `id`, `title`, `text`
        // articles is the name of our table

        // '%$query%' is what we're looking for, % means anything, for example if $query is Hello
        // it will match "hello", "Hello man", "gogohello", if you want exact match use `title`='$query'
        // or if you want to match just full word so "gogohello" is out use '% $query %' ...OR ... '$query %' ... OR ... '% $query'

        if(mysql_num_rows($raw_results) > 0){ // if one or more rows are returned do following

            while($results = mysql_fetch_array($raw_results)){
            // $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop

                echo "<p><h3>".$results['title']."</h3>".$results['text']."</p>";
                // posts results gotten from database(title and text) you can also show id ($results['id'])
            }

        }
        else{ // if there is no matching rows do following
            echo "No results";
        }

    }
    else{ // if query length ...

How to meta description get value from post?

Thanks!

How to select image from folder by name in mysql.
This is mysql query for other rows

$query = "SELECT `posts`.`id` AS `post_id`, `categories`.`id` AS `category_id`,`title`,`contents`,`date_posted`
  ,`categories`.`name` FROM `posts` INNER JOIN `categories` ON `categories`.`id`= `posts`.`cat_id`";

how to select row 'image' where is name of image and call that image from folder?

Thanks!

Thanks!

How to upload image to database and move into image folder this is my function for other rows:

<?php
function add_post($title, $contents, $category) {
    $title      = mysql_real_escape_string($title);
    $contents   = mysql_real_escape_string($contents);
    $category   = (int) $category;
    //var_dump($category);

    mysql_query("INSERT INTO `posts` SET

            `cat_id`        = '{$category}',
            `title`         = '{$title}',
            `image`         = '{$image}',
            `contents`      = '{$contents}',
            `date_posted`   = NOW()");
}

und this is post page:

<?php 
    include_once('../resources/init.php'); 

    if ( isset($_POST['title'], $_POST['contents'], $_POST['category']) ) {
            //var_dump($_POST);
        $errors = array();

        $title      = trim($_POST['title']);
        $contents   = trim($_POST['contents']);

        if ( empty($title)) {
            $errors[] = 'You need to supply a title';
        } else if ( strlen($title) > 255 ){
            $errors[] = 'The title can not be longer than 255  characters'; 
        }
        if ( empty($contents) ) {
            $errors[] = 'You need to supply some text';
        }
        if ( ! category_exists('id', $_POST['category']) ){
            $errors[] = 'That category does not exist'; 
        }

        if ( empty($errors) ) {
            add_post($title, $contents, $_POST['category']);

            $id = mysql_insert_id();

            header('location: add_post.php?id=' . $id);
            die();
        }
    }
?>

I have problem with this code show mi error Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\wamp\www\blogcode\resources\func\blog.php on line 34

function category_exists($name){
        $name = mysql_real_escape_string($name);
        $query = mysql_query("SELECT COUNT(1) FROM 'categories' WHERE 'name'= '{$name}'");
        return (mysql_result($query, 0)=='0') ? false:true;

    }

How to fix this problem?

How to make meta tag for each post in php using post for meta description?

How to make that Users on my website first click on youtubevideo open fb for share and then automatic play youtubevideo?
Example link: http://video.yuvesti.net/

How to do that active menu points use body class?

The navigation must be styled using the :hover pseudo class, while the active menu point must use the body class. How to make this?
Thanks!

How to show some articles from another website with API
example: from this web site http://shopper.cnet.com/buy-pc-games/ name of game,pictures and price to show on my website, with automatic update?

Sorry i have problem that I have not noticed
when put code for mod_rewrite for url then my css not work but when put

 RewriteRule ^(css|images|js|fonts) - [L]

then css work but url not! :(