Web-Apps and a local database

btetlow
Posts: 8
Joined: Thu May 28, 2009 5:43 am

Web-Apps and a local database

Postby btetlow » Sun Jun 28, 2009 7:17 am

I have Amahi installed and running fine, so it's time for the next step.

My wife has a small client database that I set up on a local stand alone machine. Its a simple 2 table MYSQL DB with a few simple php pages to manage it with. I followed a bouncing ball to create it to run from LOCALHOST and all was fine.

Now I want her to be able to access it from her computer and have it run on my Amahi box. I installed it according to the web-apps instructions and it worked. Well at least the index.html file come up no problem. The problems start when it tries to run an php script. It's more of a PHP issue than Amahi, I think...

The question is what do I need to change the word LOCALHOST to so that the connection is established? I thought it would just be the IP address or url of my amahi box but this doesn't seem to work. I can connect to the mysql database from my laptop from mysql command line.

Do I have to change other stuff in the mysql setup on the amahi box? Am I missing something really obvious?

Bradford

Here is the connection bit of my php code.

Code: Select all

<body OnLoad="document.getclient.client.focus();"> <form name = getclient action="SQLgetclient.php" method="get"> <?php define ('MYSQL_HOST','localhost'); define ('MYSQL_USER','user'); define ('MYSQL_PASS','password'); define ('MYSQL_DB','LMM'); $link = mysql_connect('localhost', 'user', 'password'); if (!$link) //if (mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) ) { die('Failed to connect to host "' . MYSQL_HOST . '".'); } else { echo '<br>'; // echo 'Connected to MySQL server ' . MSQL_HOST . ' as user ' . MYSQL_USER . 'on' . MYSQL_DB . '<br>'; };

User avatar
cpg
Administrator
Posts: 2618
Joined: Wed Dec 03, 2008 7:40 am
Contact:

Re: Web-Apps and a local database

Postby cpg » Sun Jun 28, 2009 4:53 pm

localhost should be fine. you do not say what error you have (check the error_log in the logs directory for the app). did you create:
  • a database
  • a user to access it
  • a password for that user?
we have a simple utility or this purpose: hda-create-db-and-user

you can simply say,

Code: Select all

hda-create-db-and-user lmm
and it will create a database called lmm, a user called lmm with a password lmm.

you can coose the user name with -u and the password with -p. you can also drop them all with -d (careful, the data will be lost forever!)

here is the usage info:

Code: Select all

bash$ hda-create-db-and-user -h Usage: hda-create-db-and-user [options] dbname -u, --user=name Specifies the user name to use. Default: dbname@localhost -d, --drop Drops the user and the DB. Default: dbname@localhost -p, --password=user Sets a specific password for the user created. Default: user name -h, --help Show this help message.
does that help?
My HDA: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz on MSI board, 8GB RAM, 1TBx2+3TBx1

btetlow
Posts: 8
Joined: Thu May 28, 2009 5:43 am

Re: Web-Apps and a local database

Postby btetlow » Sun Jun 28, 2009 7:14 pm

Thanks for that.

I stupidly spent ages setting up the databases, users, privileges, etc and I guess it's possible I made a mistake somewhere. You explanation of "hda-create-db-and-user" is much clearer than in the wiki (thanks!) so I will try that when I get home tonight.

Will post and let you know.

B.

btetlow
Posts: 8
Joined: Thu May 28, 2009 5:43 am

Re: Web-Apps and a local database

Postby btetlow » Mon Jun 29, 2009 5:28 am

cpg,

Thanks!

The simple approach worked just fine, I was obviously trying to over-complicate things.

All appears to be working just fine now.

Cheers

B.

Who is online

Users browsing this forum: No registered users and 46 guests