Jump to content

problem connecting to databse


benjahnee

Recommended Posts

hello guys

i have made a basic database in myadmin

and i have written php code to connect to it.

 

my database is called products. When i run the page i get the output -

Connection Successful could not connect to products

 

can somebody look at my code and tell me why i can not connect to my database

 

 

 

<?php


$host="localhost";
$user="";
$password="";
$db = "products";


$connect = mysql_connect($host, $user, $password);


if($connect) {
  echo "Connection Successful";
  $select = mysql_select_db($db);
  if ($select) {
 echo "<br /> connected to ".$db;
  } else { 
  echo "<be /> could not connect to ".$db;
   }
} else {
echo "failed connection";
}


?>
 

 

 
thankyou
Link to comment
https://forums.phpfreaks.com/topic/275918-problem-connecting-to-databse/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.