Posts marked with "SQL" in categories

Connecting database to both mysqli and mysql entension

You can use both mysql and mysqli extension for executing SQL queries. Here is a tutorial on how to connect both the extensions to a database. Create a file named config.php where you will connect to the database. Put the following code in it: localhost", "username", "password", "db"); if ($mysqli-connect_errno) {     echo "Failed to connect to MySQL: (" . $mysqli-connect_errno . ") " . $mysqli-connect_error; } $bd = mysql_connect("localhost", "username", "... [READ MORE]

Create Facebook Like System With jQuery, MySQL, PDO In PHP

Facebook have it’s own like system which pretty good. This post will tell you how to create a "Like system" like that of Facebook. All you have to need is jQuery, MySQL Database and PDO PHP extension. This technic is partially used in my social network, Open. See the demo there in the social network. But you have to signup. DEMO You should create a user table with users data including user id, username, password, email etc…... [READ MORE]

What is SQL Injection and how to make your PHP site free from SQL Injection hacking

SQL Injection (SQLi) is a very dangerous thing that a hacker can do to your site. This happens mostly in SQL queries. Let me make you understand this in a simple way. Suppose you’re SQL query code is this: $user=$_GET[‘user’]; $sql=mysql_query("SELECT * FROM users WHERE user='".$user."‘"); It’s a normal code. BUT it is a very easy method for hacker to easily destroy your database. The user ID is getting from a GET request.... [READ MORE]

SQL Query in another SQL Query = SQL Subquery

You might have wanted to do a SQL query inside an another SQL query. You can do this using SQL Subquery. It’s simple as ABC. Here’s an example : SELECT * FROM `fdposts` WHERE user IN (SELECT friend FROM `fdfriends` WHERE user=’subins2000′) The above code will select rows in table fdposts where user is the value of friend row in the table fdfriends. As you can see it’s very simple. Here’s another example : SELECT * FROM `posts` WHERE user IN (SELECT name FROM `members` WHERE user=’subins2000′) The above code will select rows in table posts where user is the value of the row name in the table members.... [READ MORE]

How to run/execute SQL Code

If you have installed phpMyAdmin do as below. Go to localhost/phpmyadmin/server_sql.php. Paste the SQL Code in the text box shown in the page and press GO button at the bottom right of the page. If you want to run code in PHP file do as below. Open your PHP file. Add these lines in the file. mysql_query("sql code here"); NOTE – Replace the red line with the SQL code. ... [READ MORE]

Insert XML Data to MySQL Table Using PHP

This tutorial will help you to insert XML file’s contents to a MySQL Database table using php. Note- If you can’t open PHP files in browser in Ubuntu Linux See the Tutorial : This is the XML data we are going to insert in to our MySQL Table. <span style="font-family: inherit;"<items></span <span style="font-family: inherit;" <item></span <span style="font-family: inherit;" <title>Google</title></span <span style="font-family: inherit;" <url></url></span <span style="font-family: inherit;" </item></span <span style="... [READ MORE]


Email :

Subscribe To All


If you found something helpful, please consider a donation to support this site and projects :)





This blog was once on WordPress. Now a static site. See source code on