Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 18th, 2024, 12:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 11th, 2015, 7:45 pm 
Offline

Joined: August 24th, 2015, 8:42 pm
Posts: 42
Location: Wesley Chapel, FL, USA
Opus: Opus Pro 9.x
OS: Windows 10
System: MSI Dragon Laptop - 8 Core i7, 32gb ram, 2tb hd, GeForce GTX 980
mackavi wrote:
As for the return, once you've run JSON.parse - you'll have an array - IE

Code:
myArray = windows.JSON.parse(myReturnData)


So, would this be correct?

Code:
memberData = windows.JSON.parse($return_arr);


If not, what is wrong with it?


mackavi wrote:
You can then assign array elements to the variables in your form - IE

Code:
myName = myArray[0]


So, what does the '0' represent and is this correct? Does the '0' represent the record number, such as memberID?

Code:
membername = memberData[0]


mackavi wrote:
Note, however, that you may have created a multidimensional array so will have to specify the element of the array within in the array - IE

Code:
myName = myArray[0][0]


How would I know if I created a multidimensional array?

I ordered that book, by the way.

Mike

_________________
You Dream It - We Create It
www.supersynths.com - Amazing Synths and Sounds


For this message karmacomposer has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 12th, 2015, 1:21 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
The variable you would use is whatever is specified in the Post Web Data action dialogue - in my example it's myReturnData -

http://sandbox.interaktiv.co.uk/php/fetchphp.jpg

As for the array, the zero is the index value - IE the place in the array. Depending on how the PHP data set is constructed and converted into the JSON string will depend on what values are in each element. It's probably - myArray[row-index][field-index].

You'll either have to try and see what appears for a given index combination or if you know how to use window.console.log - then you could debug the returned array and work it out that way.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 24th, 2015, 2:36 am 
Offline

Joined: August 24th, 2015, 8:42 pm
Posts: 42
Location: Wesley Chapel, FL, USA
Opus: Opus Pro 9.x
OS: Windows 10
System: MSI Dragon Laptop - 8 Core i7, 32gb ram, 2tb hd, GeForce GTX 980
When I enter the array variable (as a new variable) into Opus Pro, it does not show in the variable box nor does it appear as a variable in the drop down list but if I try to add a new variable with the same name, it tells me the variable already exists.

Here is a screen cap that shows the variable is not listed (it's called return_arr):

Image

Am I doing something wrong? This is a HTML 5 project.

Mike

_________________
You Dream It - We Create It
www.supersynths.com - Amazing Synths and Sounds


For this message karmacomposer has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 24th, 2015, 7:35 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Because that is the POST return box and you cannot and are not returning an array. The JSON data from the PHP is a string and returns to a variable such as myReturnData (a text variable).

Then you have to parse that variable into an array (like the example in the previous posts) once you are sure that the data has been returned!

Code:
myArray = window.JSON.parse(myReturnData)


This array (myArray) contains the recordset and can then be allocated to other variables used within the publication.


Code:
//JUST AN EXAMPLE!!
//Record One
myName = myArray[0][0];
myAge = myArray[0][1];
myOccupation = myArray[0][2];

//Record Two
myName = myArray[1][0];
myAge = myArray[1][1];
myOccupation = myArray[1][2];


[EDIT] should read window not windows in code above.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Last edited by mackavi on September 24th, 2015, 4:32 pm, edited 1 time in total.

Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 24th, 2015, 3:50 pm 
Offline

Joined: August 24th, 2015, 8:42 pm
Posts: 42
Location: Wesley Chapel, FL, USA
Opus: Opus Pro 9.x
OS: Windows 10
System: MSI Dragon Laptop - 8 Core i7, 32gb ram, 2tb hd, GeForce GTX 980
Is the scripting done in the php file or as html code fragments in the Opus Pro page? Where do I program this?

Mike

_________________
You Dream It - We Create It
www.supersynths.com - Amazing Synths and Sounds


For this message karmacomposer has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 24th, 2015, 4:29 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Neither.

Once you are sure the myReturnData variable has been populated, then use OpusScript to run:

Code:
myArray = window.JSON.parse(myReturnData)


//Realised there is a typo in the previous posts. Should read window not windows!

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


For this message mackavi has been thanked by : lmc


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 25th, 2015, 12:29 pm 
Offline

Joined: August 24th, 2015, 8:42 pm
Posts: 42
Location: Wesley Chapel, FL, USA
Opus: Opus Pro 9.x
OS: Windows 10
System: MSI Dragon Laptop - 8 Core i7, 32gb ram, 2tb hd, GeForce GTX 980
Mack,

Thanks for the help. Getting close to making this work - with your help.

Is the OpusScript attached to the page, an object or does it just run in the background of the page/chapter?

I know that when you run the .php script, it returns (through echo) the correct data in an array, so I KNOW that works.

The problem is in Opus Pro.

Now, I changed the array variable in the .php script to data_arr

In Opus Pro, I use the trigger, on show, to post the web data and under the destination tab, I created a text variable called data_arr to match the .php array variable.

My hopes is that the echo'd data will populate in Opus Pro in data_arr - is this correct thinking?

Now, I have a script under that (still in the on show trigger for the page) with the following:

Code:
myMemberData = window.JSON.parse($data_arr);
memberid = myMemberData[0][0];
membername = myMemberData[0][1];


The page has a form with text fields (as described previously - nothing there has changed) and the variable name is embedded in the text box.

Image

According to all that I have learned/read, this should assign the memberid and membername and the text fields should then show them - they are not.

What am i doing wrong or is the Opus Script (I assume the script object/choice is Opus Script) in the wrong place. Once I have this figured out, most of the program will come much easier.

The only other thing I need is to read the memberid and have the backward and forward buttons scroll through the various member records using the memberid as the way of reading that data from the array and then show all that in the form.

Mike

_________________
You Dream It - We Create It
www.supersynths.com - Amazing Synths and Sounds


For this message karmacomposer has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 26th, 2015, 3:09 am 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Karmac'
I want to let Mackavi stay with you and help you solve this -- especially the handling of php/mySQL, and working with the JSON string, and such. But maybe I can help track down some other issues.
karmacomposer wrote:
[partial text]The page has a form with text fields (as described previously - nothing there has changed) and the variable name is embedded in the text box.

According to all that I have learned/read, this should assign the memberid and membername and the text fields should then show them - they are not.

What am i doing wrong or is the Opus Script (I assume the script object/choice is Opus Script) in the wrong place. Once I have this figured out, most of the program will come much easier.

Did you create memberid, membername as Opus.... Page variables or Publication variables? Or is it just declared and assigned in a Script Object (or Script Action )?
IIRC, to display values of an Opus variable on Opus page, the variable must be a Page or Pub var.
It also matters HOW you got <memberid> etc into the Text-box or Text-input-box. Did you use "Insert Variable" (from the context menu)?.

If the data is not appearing on the Opus Page, you can check your variables in the Debug Pane.
Check the Helpfile for: Variable Watch tab
Quote:
The Variable Watch tab of the Script Output window allows you to see the values of Opus variables during a publication preview. This can be useful when debugging a publication to discover the values of variables without having to insert them into a text object.

To use this feature in Preview for your project...
==> Add a temporary object, say a Button obj. (optional)
==> Use an OnShow or Mouseclick Trigger, and Add an Action to it:
= ===> add a Script action and Paste-in the following one line: (without the indent arrow)
= =====> Debug.trace( membername +"\n")
==> ...then when you use Preview** and the Debug Pane comes up, explore the Watch Variable tab (add whatever variables you want to that pane). This may not work, or not work-well for "work-in-progress" HTML5 Type pubs given so many dependencies, and the reliance on the Opus publishing process to map and prepare everything.


- - - - - - Other thoughts - - - - - - -
Preview Mode** vs Published: according to Mackavi, and others, if you're doing HTML5 output -- you really want to test the work via publishing.

I'd also look at how you trigger your actions and also consider the timing here. Using the OnShow Trigger, you have a stack of several actions. For troubleshooting purposes you might want to try adding some small Delay Actions, and/or use a "Consecutive Action Group" (found under the Programming tab in standard Actions setup).

BTW, Page and Pub variables of type Array will not appear in the pop-up list of System & Publication Variables.

Good luck

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 26th, 2015, 2:33 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
karmacomposer wrote:
Is the OpusScript attached to the page, an object or does it just run in the background of the page/chapter?

Doesn't really matter, as long as you can access it. Personally, I prefer setting up functions in a script object attached to the page and calling them when necessary.

karmacomposer wrote:
In Opus Pro, I use the trigger, on show, to post the web data and under the destination tab, I created a text variable called data_arr to match the .php array variable.

My hopes is that the echo'd data will populate in Opus Pro in data_arr - is this correct thinking?

Matching is irrelevant. The PHP echo just sends data and will populate whatever string variable you've specified in POSTWEBDATA.

karmacomposer wrote:
Now, I have a script under that (still in the on show trigger for the page) with the following:

Code:
myMemberData = window.JSON.parse($data_arr);
memberid = myMemberData[0][0];
membername = myMemberData[0][1];



If this is attached to the same OnShow trigger as the POST action, it may or may not fail. It depends on how long the data takes to return from the PHP query. Generally an AJAX PHP query should be unblocking (asynchronous), this means that the script underneath (and other page code) will execute regardless of whether the PHP has yet returned the data. Clearly, this means that if try to read data that hasn't return the values will appear blank. You'll either need to keep checking the data_arr variable string or setup a suitable delay before running the code above.

If you post a live link to the example, we can see what is and isn't working.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 26th, 2015, 3:11 pm 
Offline

Joined: August 24th, 2015, 8:42 pm
Posts: 42
Location: Wesley Chapel, FL, USA
Opus: Opus Pro 9.x
OS: Windows 10
System: MSI Dragon Laptop - 8 Core i7, 32gb ram, 2tb hd, GeForce GTX 980
Mack,

Send me your email and I will send you the project file.

Code:
//Fetch the rows and loop through them
while($row = mysqli_fetch_array($result)){
   $row_array['memberid'] = $row['memberid'];
    $row_array['membername'] = $row['membername'];
    $row_array['membertitle'] = $row['membertitle'];
   $row_array['imgpicpath'] = $row['imgpicpath'];
    $row_array['membercategory'] = $row['membercategory'];
    $row_array['businessname'] = $row['businessname'];
   $row_array['officephone'] = $row['officephone'];
    $row_array['mobilephone'] = $row['mobilephone'];
    $row_array['faxphone'] = $row['faxphone'];
   $row_array['emailaddr'] = $row['emailaddr'];
    $row_array['businesswebsite'] = $row['businesswebsite'];
    $row_array['businessdesc'] = $row['businessdesc'];
   $row_array['facebooklink'] = $row['facebooklink'];
    $row_array['twitterlink'] = $row['twitterlink'];
    $row_array['linkedinlink'] = $row['linkedinlink'];
   $row_array['youtubelink'] = $row['youtubelink'];
    $row_array['myspacelink'] = $row['myspacelink'];
    $row_array['instagramlink'] = $row['instagramlink'];
   $row_array['googlepluslink'] = $row['googlepluslink'];
    $row_array['pinterestlink'] = $row['pinterestlink'];
    $row_array['isplatinummember'] = $row['isplatinummember'];
   $row_array['memberjoindate'] = $row['memberjoindate'];
    $row_array['bcfrontpic'] = $row['bcfrontpic'];
    $row_array['bcbackpic'] = $row['bcbackpic'];
   $row_array['platinumbannerpic'] = $row['platinumbannerpic'];
   $row_array['businessdesc2'] = $row['businessdesc2'];
   $row_array['businessdesc3'] = $row['businessdesc3'];
   $row_array['businessdesc4'] = $row['businessdesc4'];
   
    array_push($data_arr,$row_array);
}


That is the entire set of variables (this is a code fragment of the php send file - but all the fields in the database).

I appreciate your help in error checking or seeing what's not working or what I am doing wrong.

Mike

_________________
You Dream It - We Create It
www.supersynths.com - Amazing Synths and Sounds


For this message karmacomposer has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 26th, 2015, 5:24 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
I just need the URL of the live version.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 26th, 2015, 6:09 pm 
Offline

Joined: August 24th, 2015, 8:42 pm
Posts: 42
Location: Wesley Chapel, FL, USA
Opus: Opus Pro 9.x
OS: Windows 10
System: MSI Dragon Laptop - 8 Core i7, 32gb ram, 2tb hd, GeForce GTX 980
http://www.tampabaybusiness.org/memberdir/memberdir.htm

Mike

_________________
You Dream It - We Create It
www.supersynths.com - Amazing Synths and Sounds


For this message karmacomposer has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: How do you LOAD MySQL in HTML5 mode correctly?
PostPosted: September 27th, 2015, 11:11 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Looking at the code, the POSTWEBDATA action is returning the PHP echo to a variable called MyMemberData. This bit is working!

Then you appear to have a script action:

Code:
newMemberData = window.JSON.parse($myMemberData);

This bit is failing because there is no variable called $myMemberData it is MyMemberData.

As explained above, the delay in returning the data may not be enough to populate the variable, but you need to fix the code first!

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group