Page 1 of 1

Standalone app access to a MySQL in LC server

Posted: Sun Jul 26, 2015 10:14 am
by angelfs
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)

Re: Standalone app access to a MySQL in LC server

Posted: Sun Jul 26, 2015 7:59 pm
by Simon
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

Re: Standalone app access to a MySQL in LC server

Posted: Mon Jul 27, 2015 12:33 am
by angelfs
Dear Simon,
Problem solved!
Thank you so much.

Re: Standalone app access to a MySQL in LC server

Posted: Mon Jul 27, 2015 1:07 am
by Simon
Great!

From Sunny California!

Simon