how to establish a connection in php?
26 Dec 07
That above one is correct but we can do the same in one sentence like this $con= mysql_connect("localhost","peter","abc123") or die(mysql_error()); Put myswl_error() only for debugging purpose. For a live site show some error like "Database connection failed" within die().
19 Jan 08
Let me explain you what Swatig did, and what can be improved. But, in order for that, I need to know. Will you be handling 1 connection to the SQL server? First so, using "strings" in a function that will only be called 1 time can be done better by using variables, like: $server = "localhost"; $username = "insertusernamehere"; $password = "insertpasswordhere"; mysql_connect($server,$username,$password) or die ("Could not connect to the MySQL server, please check the connection details); This way, you don't have to declare a variable. You don't have to go if / else'ing. If you want to use the connection, you can just do mysql_query("SELECT * FROM whatever"); You don't have to use the connection declaration.
8 Jan 08
Yes you are a beginner. And we say welcome you here at mylot. You are also beginner to php and missal. These are two languages of computer sciences. These does not concern with the establishment of connection. If you want to learn these important languages of computer then you should search the related sites with the help of search engines.
1 Oct 09
HI preethivarma, I think you know the server for run the php codes.there are servers like xampp,wamp for run the php programs.for example if you use the xampp server first start the mysql and apache in xampp software.Then create a php program to connect mysql.In notepad you type the following line for connecting. if you already set the user name and password type that in user name and password field.if you don't have type root as user name and blank the password field. then next go to mysql using the following steps go to command prompt type the following c:\cd xampp\mysql\bin type the correct address of where u install the xampp.i installed it in c drive. then type c:\xampp\mysql\binmysql -u root -p then press enter then it you ask you for the password if you have the password type it if you dont have then press enter to connect with mysql.