Create a file named config.php where you will connect to the database. Put the following code in it:
... [READ MORE]
$mysqli = new mysqli("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", "password") or die(mysql_error());
mysql_select_db("db",$bd) or die(mysql_error());
?>
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.
<div>
<span style="color: red; font-family: inherit;">The table should be like this:</span>
</div>
What is SQL Injection and how to make your PHP site free from SQL Injection hacking
$user=$_GET[‘user’];
$sql=mysql_query("SELECT * FROM users WHERE user='".$user."‘");
http://example.com/user.php?user=subin
... [READ MORE]
SQL Query in another SQL Query = SQL Subquery
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′)
... [READ MORE]
How to run/execute SQL Code
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.
Insert XML Data to MySQL Table Using PHP
<pre class="prettyprint"><code><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>google.com</url></span> <span style=“font-family: inherit;"> </item></span> <span style=“font-family: inherit;"> <item></span> <span style=“font-family: inherit;"> <title>Google Accounts</title></span> <span style=“font-family: inherit;"> <url>accounts.google.com</url></span> <span style=“font-family: inherit;"> </item></span> <span style=“font-family: inherit;"></items> </span>
... [READ MORE]