Hi,sorry for the title of this thread as I not really know what to give it :)

Anyway, I got a problem with my newly created website.

My website got the blog section where I write everything onto it.And i when I try to share the link of my recent blog post on the facebook status section,the facebook fails to read the appropriate content(which is the blog post),instead it loads up the other html code that I wrote.

This is the example of blog post that i've made :

This is the snapshot when i try to share it on facebook :


So, my question is how could i make my blogpost appear when i share it's link?
I am thinking of using the meta tag description to do this,by I am not sure about thats all,so hope you guys could help & share with me the solution for this :)

Thank You..

Can you work the page to make the description meta tag, show a brief from the page?
e.g. <meta name="description" content="brief description of the blog post..." />
This should work. All the best

When I share the link on my FB page I get this:


Have you fixed it? Maybe you could post your facebook link.

Make the content of the description meta-tag change dynamically depending on the content of your page.
Are you using a custom built blog or a blogging engine like Word-press?
Check out the Share Button page on facebook
http://developers.facebook.com/docs/share

Can you work the page to make the description meta tag, show a brief from the page?
e.g. <meta name="description" content="brief description of the blog post..." />
This should work. All the best

yeah,i could simply do this,but my problem is i want the decription to be dynamic,meaning if i post a new blogpost on my website,then the decription also will change to the new one,this is what really my problem is right now..

When I share the link on my FB page I get this:
[ATTACH]18809[/ATTACH]

Have you fixed it? Maybe you could post your facebook link.

Oh sorry,no2 i just modified some of my code so it'll look more organize by erasing some of &nbsp..But it has nothing to do with this problem, and not fixing it.

Back to my problem, what i want is when i share my link www.ryzalyusoff.com on facebook,the facebook will show the decription of my latest blogpost..

Say for example my latest post is about "Downloading New Google Chrome Now!",then facebook will show the description about that post.

I hope i've explain it well,but if still unclear, feel free to ask me back :)
Help me please..

Make the content of the description meta-tag change dynamically depending on the content of your page.
Are you using a custom built blog or a blogging engine like Word-press?
Check out the Share Button page on facebook
http://developers.facebook.com/docs/share

No, i am not using any CMS for my website..I've coded that entirely using php by my own..
Help me with this please..
THanks..

By my analysis of your site, I can see that there are no specific pages for the blog posts (which is not advisable for a blog). The posts are loaded using the start url variable, which i can set to anything i like.

Let's assume you want the first 300 characters of your blog post to show:
In the <head> tag of your script, you can have something like this:

<meta name="description" content="<?php echo substr(strip_tags($blog_post), 0, 300)?>">

Where

$blog_post

represents the variable holding the content of the blog post.

I like logbon72's answer, especially since the things I tried didn't work. ;D

By my analysis of your site, I can see that there are no specific pages for the blog posts (which is not advisable for a blog). The posts are loaded using the start url variable, which i can set to anything i like.

Let's assume you want the first 300 characters of your blog post to show:
In the <head> tag of your script, you can have something like this:

<meta name="description" content="<?php echo substr(strip_tags($blog_post), 0, 300)?>">

Where

$blog_post

represents the variable holding the content of the blog post.

Oh, i dont know that..Could you show me how to make specific pages for blog posts?

And..I've tried to do like you said by writing this :

$blog_post=mysql_query("SELECT id,title,blogpost, DATE_FORMAT(timestamp,'%M %e %Y at %h:%i%p') as timestamp FROM blogpost ORDER BY id DESC LIMIT $start,$per_page");			?>
	<meta name="description" content="<?php 
	while($row = mysql_fetch_array($blog_post))
	      echo substr(strip_tags($row["blogpost"]), 0, 300)
	?>
	">

But it seems doesnt work for me :(
whats wrong?

Samsoms17, is similar to what you did, I only reorganised the code.

<?php
$start = (int) $start; //avoid sql injection;
$per_page = (int) $per_page;//avoid sql injection

$blog_post_rs = mysql_query("SELECT id,title,blogpost, DATE_FORMAT(timestamp,'%M %e %Y at %h:%i%p') as timestamp FROM blogpost ORDER BY id DESC LIMIT $start,$per_page");

if($blog_post_rs){ //check that the query was successfully executed
	//this will return the current row as an array of associative values, using the column names as key
	$description = "";
	while($row = mysql_fetch_assoc($blog_post_rs)){
		//notice the list order follows the order of your column names in the select query
		list($id, $title, $blogpost, $timestamp) = $row;  //the variable names can be anything
		//so $blogpost contains the post for the page
		$description .= substr($blogpost, 0, 300);
	}
}

?>
<!-- Somewhere inside the <head> tag -->
<meta name="description" content="<?php echo $description;?>">

To make individual pages for your blog post, you can do something like this:

<a href='blogpost.php?post=<?php echo $id?>'><!-- Title of Blog Post or Anything--><?php echo $title; ?> </a>

On blogpost.php do something like this

<?php
$id = (int) $_GET['post']; //post is the name of the variable in the url
$query = "SELECT id,title,blogpost, DATE_FORMAT(timestamp,'%M %e %Y at %h:%i%p') as timestamp FROM blogpost WHERE id={$id}";
$blog_post_rs = mysql_query($query);
if($blog_post_rs){
    //result was returned
    list($id, $title, $blogpost, $timestamp) = mysql_fetch_assoc($blog_post_rs);
}else{
    //invalid blog post ID was entered in the URL do whatever you want
    //it's also possible your query was not correctly executed
}

?>

<!-- Somewhere in the HTML Docuemnt you can do this or anything you want-->
<?php echo $title;?><br />
<?php echo $timestamp;?><br />
<?php echo $blogpost?>

Hey is this problem solved??

hey,sorry for the late reply..
yeah2,you all have solved my problem..

Thank You very much :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.