Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jh100000

macrumors newbie
Original poster
Feb 11, 2005
10
0
London, UK
I'm completely new to web database programming and I'm trying to do the equivalent of a 'hello world' application - i.e. all I want to do is create a page that will magically pull some data from a database (proof of concept if you like).

So I've got Dreamweaver, I've got MySQL setup and I've created a database and a few tables and put a bit of data into them.

When I try to create a connection one of two things happens...

If I specify a valid username/password combination I get error 1045 Access Denied for user....

Or, If I just specify any old username and no password I get two databases (not mine) 'information_schema' and 'test' which I can happily query.

But i want to query my database.....
 

Mitthrawnuruodo

Moderator emeritus
Mar 10, 2004
14,424
1,065
Bergen, Norway
Where have you set up the new MySQL database? Have you specified your php script to use that server?

I may also help if you post the code from the php file (use the php tags)... ;)

Edit: In particular the database info, like this:

PHP:
$DB_Host="whatever.server.domain";
$DB_Name="your_database";
$DB_User="db_user";
$DB_Pass="******";

$link = mysql_connect($DB_Host, $DB_User, $DB_Pass);
and the queries
PHP:
$query = "SELECT whatever FROM table WHERE something matches";
$result = mysql_db_query($DB_Name, $query, $link);
 

superbovine

macrumors 68030
Nov 7, 2003
2,872
0
just another way with different type of error checking. The php script will die if doesn't connect the db.

PHP:
//connect to the database server

	define('DB_USER', 'user name');
	define('DB_PASSWORD', 'password here');
	define('DB_HOST','localhost or addy');
	define('DB_NAME', 'db name');

      //@ turns off messages
	$dbc = @mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
	
	if(!$dbc) {
	  die( '<p>Unable to connect to the ' .
		'database server at this time. </p>' );

	}

	if(! @mysql_select_db(DB_NAME) ) {
	  die( '<p>Unable to locate the DB_NAME ' .
		'database at this time.</p>' );
	}


?>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.