Standalone app access to a MySQL in LC server

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
angelfs
Posts: 3
Joined: Wed Jan 14, 2015 8:11 pm
Location: Barcelona - Spain

Standalone app access to a MySQL in LC server

Post by angelfs » Sun Jul 26, 2015 10:14 am

Hi all,

I'm just starting with LiveCode and have only few notions about coding, so my below questions are of begginer level.

I'm working on my first app and trying to access a MySQL database hosted in an LC server with no success.

Understood that, for security reasons some servers do not allow to directly access a database from outside. In accordance to what I've been able to understand after reading some posts in the forum, I must set a middleware in between my app and the database.

I've wrote this small php file to set my connection and to :

Code: Select all

<?php

$hostname = "host";
$database = "database";
$username = "user";
$password = "password";
$connLivecode = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);

mysql_select_db($database, $connLivecode);
$query = "SELECT * FROM `table_name`";
$result = mysql_query($query, $connLivecode) or die(mysql_error());

?>
And I'm getting the following error messages:

Code: Select all

( ! ) Warning: mysql_pconnect(): Access denied for user 'user'@'host' (using password: YES) in /home/anotion/public_html/exemple.php on line 7
Call Stack
#	Time	Memory	Function	Location
1	0.0001	228328	{main}( )	.../exemple.php:0
2	0.0001	229536	mysql_pconnect ( )	.../exemple.php:7

( ! ) Fatal error: Access denied for user 'user'@'host' (using password: YES) in /home/anotion/public_html/exemple.php on line 7
Call Stack
#	Time	Memory	Function	Location
1	0.0001	228328	{main}( )	.../exemple.php:0
2	0.0162	230392	trigger_error ( )	.../exemple.php:7
The user 'user' has been duly activated in the MySQL by the cPanel.

My questions are:

- is this middleware a php file in my domine in the LC server?
- should it be placed in the 'public/html' folder in 'my domain' at 'on-rev''? or where?
- where can I find the host name were my database is located?
- what I'm doing wrong or not doing?

Any help is very welcome ... I'm desperate.

Thank you in advance from sunny Spain 8)
Angel Fernández

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Standalone app access to a MySQL in LC server

Post by Simon » Sun Jul 26, 2015 7:59 pm

Hi Angel,
If you have access to cPanel then there are easier ways to connect.
http://forums.livecode.com/viewtopic.ph ... 56#p106882
All php is handled through cPanel you don't have to write anything (well almost).
Make sure you check out shawnblc's answer in that thread (remote mysql) as well as I think that is the real answer to your problem.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

angelfs
Posts: 3
Joined: Wed Jan 14, 2015 8:11 pm
Location: Barcelona - Spain

Re: Standalone app access to a MySQL in LC server

Post by angelfs » Mon Jul 27, 2015 12:33 am

Dear Simon,
Problem solved!
Thank you so much.
Angel Fernández

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Standalone app access to a MySQL in LC server

Post by Simon » Mon Jul 27, 2015 1:07 am

Great!

From Sunny California!

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply

Return to “Databases”