Forum Moderators: coopster

Message Too Old, No Replies

php cannot select db

         

jason_m

2:48 am on Aug 25, 2010 (gmt 0)

10+ Year Member



okay. i am successfully connecting but i cannot select my db.

i really feel as if i have tried anything and could use some pointers.

thanks


<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');


$host="host.org"; // Host name
$username="myServer_guest"; // Mysql username
$password="password"; // Mysql password
$db_name="myServer_JMblog"; // Database name
$tbl_name="blog"; // Table name


$link=mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

?>

rocknbil

4:21 am on Aug 25, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$host="host.org"; // Host name

Are you sure?

It's usually just 'localhost' or somedomain.mysql.com or something . . . it won't be the same as your domain name. Try changing it to 'localhost' right off the bat, see if that works.

Anyango

7:34 am on Oct 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



try
or die(mysql_error());
rather than die("cannot connect");

That could tell the exact reason, it mabye the host as rocknbil said and it maybe the incorrect login information.