Connecting to a database on my computer

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
nick2
Forum Contributor
Posts: 118
Joined: Fri Jul 25, 2003 2:34 pm

Connecting to a database on my computer

Post by nick2 »

Well I run a gameserver and I want to connect to one of the dbs and echo the ids.

Code: Select all

<?
   $db_name = "ID.DB";
   $table_name = "ID";

   $connection = mysql_connect("24.185.8.160") or die(mysql_error());
   mysql_select_db($db_name) or die(mysql_error());

   $result = mysql_query("SELECT * FROM "ID.DB") or die(mysql_error());

   if (mysql_num_rows($result)>0){
   echo $result;
?>

Code: Select all

in db commander when i click mysql it shows me this command to use:

Select *From "ID.DB"

Also theres no set id and password so does it matter?
User avatar
nick2
Forum Contributor
Posts: 118
Joined: Fri Jul 25, 2003 2:34 pm

Post by nick2 »

actually i fixed it, now I get:

Access denied for user: '@ns3.concordhosting.com' to database 'ID.DB'
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

You need to set up permissions in your MySQL. There's a Hosts table and a User table; you may find editing them from the command line to be a nightmare, however.

You'll want to define a username and password to connect to your database, first. And don't use 'root.'
User avatar
nick2
Forum Contributor
Posts: 118
Joined: Fri Jul 25, 2003 2:34 pm

Post by nick2 »

um ... i'm just running a game server.. in a editor viewer it told me that.

anyway I got it working kind of.. and I have 6 ids and passes.

it doesn't load now lol..

Code: Select all

<?php
   $db_name = "ID.DB";
   $table_name = "ID";

   $connection = mysql_connect("24.185.8.160:7200, 'administrator', 'amir#051' ") or die(mysql_error());
   mysql_select_db($db_name) or die(mysql_error());

   $result = mysql_query("SELECT * FROM 'ID.DB' ") or die(mysql_error());

   echo $result;
?>
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

So what's it doing? You've got a lot of mysql_error()'s in there, one of them must be telling you something.
User avatar
nick2
Forum Contributor
Posts: 118
Joined: Fri Jul 25, 2003 2:34 pm

Post by nick2 »

ok any idea what this means:

Access denied for user: '@ns3.concordhosting.com' to database 'ID.DB'

code:

Code: Select all

<?php
   $db_name = "ID.DB";
   $table_name = "ID";

   $connection = mysql_connect("24.185.8.160:3306, 'zura', 'ohyes!' ") or die(mysql_error());
   mysql_select_db($db_name) or die(mysql_error());

   $result = mysql_query("SELECT * FROM 'ID.DB' ") or die(mysql_error());

   echo $result;
?>
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

I already told you. You haven't set up a user account in MySQL or opened up access for the ns3.concordhosting.com machine. Until you fix that, your script won't be able to connect.
User avatar
nick2
Forum Contributor
Posts: 118
Joined: Fri Jul 25, 2003 2:34 pm

Post by nick2 »

I'm using BDE Administrator

please look into it..

I dont' know how to setup an account for it.

see its a online game and theres 6 servers...i dunno what I connect to.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You need to setup the privileges within MySQL - is MySQL on your computer or are you connecting to a remote db server, i.e. is 24.185.8.160 your IP address or someone elses?

What is BDE Administrator and what are you using it for?

Mac
User avatar
d-m
Forum Commoner
Posts: 31
Joined: Fri Aug 29, 2003 4:24 pm
Location: Rio de Janeiro - RJ - Brasil

Post by d-m »

twigletmac wrote:You need to setup the privileges within MySQL - is MySQL on your computer or are you connecting to a remote db server, i.e. is 24.185.8.160 your IP address or someone elses?

What is BDE Administrator and what are you using it for?

Mac
BDE is a product from Borland that you can connect to the database and/or admin a database it cames with Delphi, C++ Builder, Kylix etc ...

But the situation that you have, is not Problem of BDE, As the people told U, you have to enter at the MySql databe and set a user / pass / host in orther to connect .

please check the MySql manual at the Administration part - Adding a new user to Mysql.

There explains step by step how to do it!

RTFM guys! :lol:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

d-m wrote:BDE is a product from Borland that you can connect to the database and/or admin a database it cames with Delphi, C++ Builder, Kylix etc ...
That's what I assumed from my googling - but I couldn't find a product page so just wanted to check. As d-m stated based on that this can't be a BDE problem, you need to get into MySQL directly and do administration within that.

Mac
Post Reply