From: Paul Swanson on
Kevin, you shouldn't need to worry about ODBC or OLEDB. Your PHP script
needs to handle the database connection, and you can use PHP's
mysql_connect() function for that. You really don't need to do anything
different for Authorware than you do for any PHP/MySQL application in terms
of connecting to the database.

My PHP script returns data to AW in the form of name=value pairs delimited
by the ampersand character. I then use the following code in AW to convert
them into lists:

=========================
-- Use this routine to break queryString into name / value arrays.
-- Assumes a database query returns a string of name=value pairs
-- delimited by the ampersand (&) character.

-- strip leading & from queryString
queryString := SubStr(queryString, 1, CharCount(queryString))

-- break into list of individual lines
tempList := Replace("&", Return, queryString)

listLength := LineCount(tempList)

-- create empty arrays for name and value
name := Array("", listLength)
value := Array("", listLength)

repeat with counter := 1 to listLength
singleLine := GetLine(tempList, counter)
name[counter] := GetWord(1, Replace("=", " ", singleLine))
value[counter]:= GetWord(2, Replace("=", " ", singleLine))
end repeat

-- now you will need to add a separate calc icon with a routine to
-- read the data from the arrays. name[counter] matches value[counter]
=========================

I follow this with another Calc icon (I could have done it all in one calc)
that parses the names and assigns the values to my custom AW variables:

=========================
-- get just the info we want, and store in variables

repeat with counter := 1 to listLength
if name[counter] = "Lesson1Complete" then
Lesson1Complete := Number(value[counter])
else if name[counter] = "Lesson2Complete" then
Lesson2Complete := Number(value[counter])
else if name[counter] = "Lesson3Complete" then
Lesson3Complete := Number(value[counter])
else if name[counter] = "Lesson4Complete" then
Lesson4Complete := Number(value[counter])
else if name[counter] = "Lesson5Complete" then
Lesson5Complete := Number(value[counter])
else if name[counter] = "Lesson6Complete" then
Lesson6Complete := Number(value[counter])
else if name[counter] = "Lesson7Complete" then
Lesson7Complete := Number(value[counter])
else if name[counter] = "Lesson8Complete" then
Lesson8Complete := Number(value[counter])
else if name[counter] = "OverviewComplete" then
OverviewComplete := Number(value[counter])
else if name[counter] = "grade" then
score := Number(value[counter])
else if name[counter] = "passed" then
passed := Number(value[counter])
end if
end repeat
=========================

There may be more efficient ways to do this (such as using Property Lists),
but with a small recordset like mine, this works great.

--
_______________________

Paul Swanson
Portland, Oregon, USA
_______________________


"kjedwards" <webforumsuser(a)macromedia.com> wrote in message
news:ee9mdp$68u$1(a)forums.macromedia.com...
> Hi Amy
>
> My host provides Windows Server hosting as well as UNIX and so it would
be
> possible to connect AW through to say MS Access or MSSQL.
>
> The AW app I am thinking about developing would be hosted on the web so
client
> connectivity should not be a problem.
>
> I have to say that although I have developed several dynamic web sites
using
> php/mysql, I have never developed anything using Coldfusion, ASP or MSSQL.
>
> I do understand that my host may very well provide some kind of ODBC
> connectivity (hosted web sites to hosted access/mssql) but judging by the
> number of issues ODBC has raised on the hosts support forum it seems to be
a
> undesireable way forward. Almost everyone suggests using OLEDB connections
> rather than ODBC. So I am rather put off.
>
> I can work with PHP reasonably well but (although played around with AW
on and
> off for some time) don't know AW that well. The lack of a good scripting
> /programming guide is a real downer for an app like AW which costs so
much.
>
>
> Yours
>
> Kevin
>
>


From: kjedwards on
Hi Paul

Many thanks for that - it is appreciated.

I have managed to get something working, I have seperated the field data in
PHP with a ~ and seperated each record with a |. Then used a combination of
LineCount and a couple of GetLine's to extract the data. I managed to add
these to a multi-dimentional array - Number of rows = number of lines in the
returned string. I already know the number of fields per record so that was the
number of columns in the array.

Worked ok, or at least I can now access the data in AW.

There are some really good pointers in your post and I will have a closer look
tomorrow - I am in the UK so it's 10pm here.

Thanks again

Yours

Kevin

From: Amy Blankenship *AdobeCommunityExpert* on

"kjedwards" <webforumsuser(a)macromedia.com> wrote in message
news:ee9mdp$68u$1(a)forums.macromedia.com...
> Hi Amy
>
> My host provides Windows Server hosting as well as UNIX and so it would be
> possible to connect AW through to say MS Access or MSSQL.

You can connect to Access either on Unix or Windows, though I don't think
SQL Server can be installed on Unix.

> The AW app I am thinking about developing would be hosted on the web so
> client
> connectivity should not be a problem.
>
> I have to say that although I have developed several dynamic web sites
> using
> php/mysql, I have never developed anything using Coldfusion, ASP or MSSQL.

They were just examples. They all work in pretty much the same way, except
SQL Server, which is a database and not a means of access.

> I do understand that my host may very well provide some kind of ODBC
> connectivity (hosted web sites to hosted access/mssql) but judging by the
> number of issues ODBC has raised on the hosts support forum it seems to be
> a
> undesireable way forward. Almost everyone suggests using OLEDB connections
> rather than ODBC. So I am rather put off.

The host _does not have_ to provide connectivity if you use DSN'less
connections. I don't think that one is more problematical than the other.
You just have to know which one you are using and how it may affect the SQL
syntax for the database in question. It may be that mySQL has issues with
ODBC connections, but I doubt it. For more info, try here
http://www.carlprothman.net/Default.aspx?tabid=90#ODBCDriverForMySQL.

> I can work with PHP reasonably well but (although played around with AW on
> and
> off for some time) don't know AW that well. The lack of a good scripting
> /programming guide is a real downer for an app like AW which costs so
> much.

Huh? There's a functions and variables reference in the Help. Though I do
agree that the elimination of this guide from the printed manual is a bit of
a pain. I can send you the pdf functions and variables reference last
provided in 6.5, if that would help you. If you want it, edit my e.mail
address as seems logical, then send me a mail off list.



From: Amy Blankenship *AdobeCommunityExpert* on

"Paul Swanson" <Paul.Swanson(a)nospam.harlandfs.com> wrote in message
news:ee9ogg$8nq$1(a)forums.macromedia.com...
> Kevin, you shouldn't need to worry about ODBC or OLEDB. Your PHP script
> needs to handle the database connection, and you can use PHP's
> mysql_connect() function for that. You really don't need to do anything
> different for Authorware than you do for any PHP/MySQL application in
> terms
> of connecting to the database.
>
> My PHP script returns data to AW in the form of name=value pairs delimited
> by the ampersand character. I then use the following code in AW to convert
> them into lists:
>
> =========================
> -- Use this routine to break queryString into name / value arrays.
> -- Assumes a database query returns a string of name=value pairs
> -- delimited by the ampersand (&) character.
>
> -- strip leading & from queryString
> queryString := SubStr(queryString, 1, CharCount(queryString))
>
> -- break into list of individual lines
> tempList := Replace("&", Return, queryString)
>
> listLength := LineCount(tempList)
>
> -- create empty arrays for name and value
> name := Array("", listLength)
> value := Array("", listLength)
>
> repeat with counter := 1 to listLength
> singleLine := GetLine(tempList, counter)
> name[counter] := GetWord(1, Replace("=", " ", singleLine))
> value[counter]:= GetWord(2, Replace("=", " ", singleLine))
> end repeat
>
> -- now you will need to add a separate calc icon with a routine to
> -- read the data from the arrays. name[counter] matches value[counter]
> =========================
>
> I follow this with another Calc icon (I could have done it all in one
> calc)
> that parses the names and assigns the values to my custom AW variables:
>
> =========================
> -- get just the info we want, and store in variables
>
> repeat with counter := 1 to listLength
> if name[counter] = "Lesson1Complete" then
> Lesson1Complete := Number(value[counter])
> else if name[counter] = "Lesson2Complete" then
> Lesson2Complete := Number(value[counter])
> else if name[counter] = "Lesson3Complete" then
> Lesson3Complete := Number(value[counter])
> else if name[counter] = "Lesson4Complete" then
> Lesson4Complete := Number(value[counter])
> else if name[counter] = "Lesson5Complete" then
> Lesson5Complete := Number(value[counter])
> else if name[counter] = "Lesson6Complete" then
> Lesson6Complete := Number(value[counter])
> else if name[counter] = "Lesson7Complete" then
> Lesson7Complete := Number(value[counter])
> else if name[counter] = "Lesson8Complete" then
> Lesson8Complete := Number(value[counter])
> else if name[counter] = "OverviewComplete" then
> OverviewComplete := Number(value[counter])
> else if name[counter] = "grade" then
> score := Number(value[counter])
> else if name[counter] = "passed" then
> passed := Number(value[counter])
> end if
> end repeat

I'd like to point out here that any time you have a series of variables that
all have identical names except for a number in the variable name, you
should be looking at lists. I'm surprised, Paul, that you have lists used
to the extent that you're able to use Value[counter] on the right side of
the equation, yet you're not using lists on the left side of the equation.
Let's look at how this code could be made super simple by having ONE list
variable, LessonComplete, instead of Lesson1Complete through
Lesson8Complete.



-- Assumes a database query returns a string of name=value pairs
-- delimited by the ampersand (&) character.

-- strip leading & from queryString
--(note you could also not add this ampersand on the PHP side)
queryString := SubStr(queryString, 1, CharCount(queryString))

-- break into list of individual lines
tempList := Replace("&", Return, queryString)

listLength := LineCount(tempList)

-- create empty arrays for name and value
name := Array("", listLength)
LessonComplete := []

repeat with counter := 1 to listLength
singleLine := GetLine(tempList, counter)
name[counter] := GetWord(1, Replace("=", " ", singleLine))
LessonComplete[name[counter] * 1] := GetWord(2, Replace("=", " ",
singleLine))
end repeat

-- now you will need to add a separate calc icon with a routine to
-- read the data from the arrays. name[counter] matches value[counter]

--No you don't...You're DONE :-)

Also note that this is extensible...you can have Lesson 9, 10, etc. and not
have to change the code. You can also lower the amount of data being
transmitted, because now instead of Lesson8Complete=1 all you need is 8=1.
This lowers the server load and speeds the response. It has advantages on
the Authorware side as well, because if, for instance, you had a series of
buttons that were checked or not based on the completion, you could do the
same type of loop. Separate variable names do not allow for that type of
loop unless you use Eval (ugh).

HTH;

Amy


From: Paul Swanson on
[Quote from Amy]
I'm surprised, Paul, that you have lists used
to the extent that you're able to use Value[counter] on the right side of
the equation, yet you're not using lists on the left side of the equation.
[/quote]

Yeah, I knew it was kludgy. ;o)

I think it came from creating the AW variables first, then figuring out how
to communicate with a database. Once I had something working I've kept
re-using it with only minor tweaks. Plus I have lots to learn still on how
to use Lists efficiently. I'm keeping your suggestion in my tips folder!

I guess that's why you're an ACE, and I'm just a joker!

--
_______________________

Paul Swanson
Portland, Oregon, USA
_______________________



First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: unable to execute user function
Next: Shell Error 5