Page 1 of 1

Connecting to a database on my computer

Posted: Mon Sep 08, 2003 6:28 pm
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?

Posted: Mon Sep 08, 2003 6:30 pm
by nick2
actually i fixed it, now I get:

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

Posted: Mon Sep 08, 2003 6:35 pm
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.'

Posted: Mon Sep 08, 2003 6:38 pm
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;
?>

Posted: Mon Sep 08, 2003 6:53 pm
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.

Posted: Mon Sep 08, 2003 6:53 pm
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;
?>

Posted: Mon Sep 08, 2003 7:00 pm
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.

Posted: Mon Sep 08, 2003 7:15 pm
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.

Posted: Tue Sep 09, 2003 4:12 am
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

Posted: Tue Sep 09, 2003 9:50 am
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:

Posted: Tue Sep 09, 2003 10:13 am
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