// first of all we will check string lengthif(strlen($post) > 11){ // if post id is bigger than 11 charachtersdie('Blog post nof found.');}// now we will make sure that the post id is numeric and this is a nice security methodif(is_numeric($post)){ // is numeric allows numbers only$post = (int)$post; // and the int function, which replace every// string to its correspoing number

// for the tutorial im gonna add mysql_real_escape_string// but is not really needed in this case$post = mysql_real_escape_string($post); // final sqli defense

I used LIMIT 1 on the first mysql query.
That's done for 2 main pruposes:
1. we are only displaying 1 result
2. it's a nice speed optinization for mysql
To display blog posts by newest ones replace

SELECT title, id FROM posts
with SELECT title, id FROM posts ORDER BY id DESC
It's a simple blog who does the work.
If you want to learn more about sql injection we suggest Sql Injection prevention tutorial

83 comments:

Really like that you are providing such information on PHP MYSQl with JAVASCRIPT ,being enrolled at http://www.wiziq.com/course/5871-php-mysql-with-basic-javascript-integrated-course i really thank you for providing such information it was helpful.

Creating Experts provide Real Time scenarios php training in Chennai.At creating experts the trainers have around 8+ years of experience.They teach the advance level topics by giving real time examples.

Contact us: 8122241286, 9003085882 – Karthick

Here everything is practical basis not any classroom training.The trainers are working in mnc's and they will take classes only on Saturday and Sunday.

Creating Experts provide Real Time scenarios php training in Chennai.At creating experts the trainers have around 8+ years of experience.They teach the advance level topics by giving real time examples.

Contact us: 8122241286, 9003085882 – Karthick

Here everything is practical basis not any classroom training.The trainers are working in mnc's and they will take classes only on Saturday and Sunday.

Awesome post for Freshers and PHP professionals those who are in search of job or someone working in Non IT sector and desire to extend their skill sets to be a PHP Web Developer.Thanks for sharing appropriate info.

The tutorial is best suited for Freshers who are in search of job or someone working in Non IT sector and desire to extend their skill sets to be a PHP Web Developer. This tutorial is also suited for people who want to migrate from other scripting languages like asp.net, cold fusion, perl, jsp to the rewarding world of PHP 5 and Zend Framework.Thanks for sharing.

hi i have the actual problem, when i click to a post , give me this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/CCCCC/public_html/index.php on line 84 Line 84 is // final part$query = mysql_query("SELECT title, FROM posts WHERE id=$post LIMIT 1"); while($row = mysql_fetch_array($query)){echo $row['title'];}please help!

Its really helpful for me to understand where we i lost in my previous interview. Thanks. If anyone wants to Learn oracle in Chennai go to the Besant Technologies which is No.1 Training Institute in Chennaihttp://www.oracletraininginchennai.in

I got a job by saying this answer in my last interview. thanks for awesome help. I got more idea about Oracle from Besant Technologies. If anyone wants to get oracle Training in Chennai visit Besant Technologies.

Great discussion and inform on where is web design going in 2016. Each and every year web design is growing and plenty of innovative and impressive things are shared and published every day.e-commerce web designs

Pls i need a blog for my set of Novices brothers... but im struggling to create one... i don't need a host.. i need a simple but good and free one... i would really appreciate you help me create one.. you could create a new email and link to my email androvishberrian@gmail.com