• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Wednesday, August 1, 2012

CONNECTION IN PHP


Hi… welcome to my blog in “We Are Knoewledge” Iwant giving you IT knowledge in here… you can follow me for easely in learn…

Now, I wan giving you tutor PHP about making file “connection”.. you know what for this file… ??
Yes that’s right.. this file usefull connection between file.php with database in mysql…

For more details we direct to progam coding..

1. frist you must creating database in mysql and the tutorial was I made in 

If you was understandand and making you just make conection.php..

You can copy this coding or you write self in orde to you can more easily in undestand..

<?php
$host = "localhost";
$user = "root";
$pass = "";
$db   = "adsanse";
$a = mysql_connect($host, $user, $pass);
$b = mysql_select_db($db, $a);
if ($b)
{
Echo "your connection is ready";
}
Else
{
Echo "your connection is failed, maybe your query is wrong, please check again";
}
?>


Note :

  • If you using copy + paste you must change all quotes (“) if you not change the file error
  • Save with save as type “PHP” ex : connection.php.
  • Put in folder “htdoc” in xampp
  • For working please trun on in xampp is “apache” and “mysql”..
  • Open your search engine and write “localhost/connection.php” >> enter
  • $host = "localhost";   >> server from xampp you should not be to change
  • $user = "root";           >> this should not be to change too
  • $pass = "";                    >> because the xampp not use pass, then pass we are clear
  • $db   = "adsanse";     >> this is name of database
  • Syntax for connecting :
  • $a = mysql_connect($host, $user, $pass);
  • $b = mysql_select_db($db, $a);


If to result is :
connection is failed, maybe your query is wrong, please check again
your program is true

If to result is :
your connection is failed, maybe your query is wrong, please check again
your program to be something errors.


Ok.. just for it…
I hope you understand with my article…
Thanks for the readers….
See you later

No comments:

Post a Comment