0

I'm trying to connect database. Here's the details of my work:

$con=mysql_connect("localhost", "root","");
mysql_select_db("employees",$con);
if(!$con)
{
die("cant establish database connection".mysql_error());
}
else
{
echo "connection Created";

where in xamp my database,which i created in phpmyadmin in localhost xamp, is on the following directory:

 C:\xampp\mysql\data

Here a folder named Employees is created then it has some files in it. when i run php file to create connection it shows nothing on the screen according to my code it must show :

  connection created

now can anyone tell me where im wrong? why its not showing any output?

Isaac Bennetch
  • 10,266
  • 2
  • 27
  • 38
usman razzaq
  • 31
  • 1
  • 5

1 Answers1

3

If that's your whole script, you're missing a closing brace at the end }.

Turn on error display, it will be useful in the future: How do I get PHP errors to display?

Also have a read of this: Why shouldn't I use mysql_* functions in PHP?

Community
  • 1
  • 1
rjdown
  • 8,530
  • 3
  • 23
  • 39
  • '}' it is there just in copying somehow i missed, and can u tell me about every other things am I doing good or not? – usman razzaq May 16 '15 at 11:25
  • You should check if the connection succeeded before you select the database. Everything else is in the links above. – rjdown May 16 '15 at 13:32