Forums/Other/SQL Yoga

Answered

dbconn_set failing

claudi.c
asked this on November 04, 2009 11:43

Hello,

I try to connect to my on-rev mysql database from a normal stack.

The statement dbconn_set "host", "www.claudi.on-rev.com" fails with:

An error occured while connecting to the database: 348,0,0,invalid array type for connection

348,0,0,_ValidateConnectionArray(1631)

etc,

Obviously www.claudi.on-rev.com isn't the right parameter. I tryed without the www part but that fails aswell.

I wonder what the right parameter should be.

Claudi

 

Comments

User photo
Trevor DeVore
Blue Mango Learning Systems

There error message actually makes me think that you are trying to set a Connection object property when no Connection object exists.

Try executing the followingin the message box:

[code]put dbobject_get("default connection")[/code]

what does it print out?

On a somewhat related note, I've uploaded 1.0 build 13 which includes better error reporting for Database and Connection object errors. You may want to grab that library from the SQL Yoga page.

http://www.bluemangolearning.com/revolution/software/libraries/sql-yoga/

November 04, 2009 12:22
User photo
claudi.c

Hi Trevor,

I downloaded the new lib and started all over again following your sqlYoga manual

I now get past the dbconn_set call. I probably did something wrong the first time.

And I guess I am still doing something wrong, 'cause now the connection fails.

I tryed also to connect without sqlYoga just to figure out what's wrong. So I did

put "www.claudi.on-rev.com:3306" into _dbHost ( I tryed with and without port number, and with and without www)

put "claudi_onrevStats" into _dbName

put "claudi_claudi" into _dbUser

put "*****" into _dbPass (actualy the right password)

put revOpenDatabase("mysql", _dbHost, _dbName, _dbUser, _dbPass) into DB

I get the following error: Access denied for user 'claudi_claudi'@'ip-55bf816a.wldsl.nl' (using password: YES)

If I use the same with irev, except I change the host to localhost, I can connect perfectly to my database.

This puzzles me a bit. Only the host part is different, so I think there is the fault, but how it should be beats me.

I hope someone has a sugestion

Claudi

November 04, 2009 16:16
User photo
Trevor DeVore
Blue Mango Learning Systems

By default a database on on-rev cannot be accessed from outside hosts. This is for security reasons. You can change your settings in cPanel to allow remote access however. Here are some instructions on how you can change your settings so that any host can connect to your database. This will allow you to test the connection to your database.

[h]Allow Remote Access To MySQL Database in cPanel[/h]

This lesson will show you how to allow [color=#FF0000][b]ANY[/b][/color] remote connection to your On-Rev MySQL server. This is turned off by default for security reasons.

[b]Open On-Rev cPanel page[/b]

[img]http://bluemangolearning.com/download/shared_images/2009/11/6/4Zt19...

[b]Click on Remote MySQL[/b]

[img]http://bluemangolearning.com/download/shared_images/2009/11/6/4Zt19...

In the Databases section click on the [b]Remote MySQL[/b] link.

[b]Add % To Access Host[/b]

[img]http://bluemangolearning.com/download/shared_images/2009/11/6/4Zt19...

Enter [b]%[/b] into the host field (1) and click [b]Add Host[/b] (2). This allows a connection to the server from ANY host.

[img]http://bluemangolearning.com/download/shared_images/2009/11/6/4Zt19...

After the Access Host is added you will see this screen. Click [b]Go Back[/b] to return to the main Access Host screen.

[b]Access Host Has Been Added[/b]

[img]http://bluemangolearning.com/download/shared_images/2009/11/6/4Zt19...

You should now see [b]%[/b] in the list of Access Hosts.

November 04, 2009 21:46
User photo
claudi.c

Hi Trevor,

Thanks for this very helpful and clear explanation, your great.

So actually instead of a standalone it would be better, for security reasons, to do the whole thing as a revlet.

Well ok, I'll have to learn the whole lot anyway, so why not start right away.

But being able to turn the safety off for testing tough, is quit usefull.

Thanks a lot.

Claudi

November 05, 2009 11:54
User photo
Trevor DeVore
Blue Mango Learning Systems

Actually a revlet still has the same security issues as it runs on the end users computer. That means it has to communicate with the database remotely.

Some people do connect directly to databases using remote connections and the SSL option. This is typically frowned upon however. What you usually do instead is put some application logic in between the remote application and the database. This could be an irev or PHP script for example. How important this is depends on your data and how your application will be used.

I've been thinking quite a bit about a server module for SQL Yoga that would become this intermediary. You would place a file on your server that SQL Yoga would communicate with. This would just be another connection type for SQL Yoga. At this point all I have are thoughts running around in my head though so no immediate solutions.

November 05, 2009 12:03
User photo
claudi.c

I certainly would be interested in such a module.

Would it be possible to use a revlet for displaying the data and irev to get the data?

If this would be possible, what would be the best way to get the data to the revlet.

Sorry for all these 'beginners' questions, but this is all new for me and it's hard to get an overview

of each area and how they all fit together.

How do you know, what you don't know?

Best wishes,

Claudi

November 05, 2009 12:23
User photo
Trevor DeVore
Blue Mango Learning Systems

Yes, you could use irev files running on the server to communicate with the revlet. Here is how I would do it:

1) Create an irev page that queries a database and converts the cursor to an array. There is a lesson in the Data Grid Tips & Tricks manual that shows how to do this.

Converting a Database Cursor To a Data Grid Array

Have the irev page encode the array using arrayEncode and then return this value to the program that requests the iRev page.

2) Create a revlet that queries the irev page you created. It should take the data that is returned and decode it using arrayDecode. Now you have an array in your revLet that you can manipulate.

November 05, 2009 12:33
User photo
claudi.c

Great.

Just one more question, how does the revlet querry the irev page?

Claudi

November 05, 2009 14:06
User photo
Trevor DeVore
Blue Mango Learning Systems

[code]put URL "http://mydomain.com/mypage.irev" into theData[/code]

If your irev page returned an encoded array then you would decode it like this:

[code]put arrayDecode(theData) into theArrayA[/code]

November 05, 2009 15:48