php and supercard-generated files

Here's where to discuss topics that have nothing to do with using SuperCard, but may be of interest to the membership.

php and supercard-generated files

Postby IndigoRose » Thu Jun 30, 2011 10:59 am

Hi all,
I have a SC project that generates massaged data that I want to be able to use in creating a web page. Is there anyone familiar enough with php to tell me how to use php to pick up an output file generated by SC, and use it to generate a web page?

I used to use SC quite a bit back when it was experimenting with cross-platform and web applications. I understand that this functionality is no longer available, and I am trying to come up with a work-around to resurrect this project.

Thanks, Indigo
IndigoRose
 
Posts: 6
Joined: Wed Jun 29, 2011 9:41 am

Re: php and supercard-generated files

Postby johnjohnston1 » Thu Jun 30, 2011 10:23 pm

IndigoRose wrote:Hi all,
I have a SC project that generates massaged data that I want to be able to use in creating a web page. Is there anyone familiar enough with php to tell me how to use php to pick up an output file generated by SC, and use it to generate a web page?

I used to use SC quite a bit back when it was experimenting with cross-platform and web applications. I understand that this functionality is no longer available, and I am trying to come up with a work-around to resurrect this project.

Thanks, Indigo

Hi,
You could use SC to generate the webpage(s). the merge function was designed for that.
I've a rather old, rather simple, tutorial on that:
http://www.littlefishsw.co.uk/card/howt ... index.html
The other way would to be upload your data as a text file and to parse that with php that would depend on your data and how you want the whole thing to look etc. I've done a bit of that but my php is pretty basic.
If it is static pages you are generating, ie not using php for search or manipulation, you might be better generating static webpages with SC. (SuperCard can also handle the ftping of html files to the website through the use of curl in the shell function.)

cheers

john
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: php and supercard-generated files

Postby IndigoRose » Fri Jul 01, 2011 5:18 am

"The other way would to be upload your data as a text file and to parse that with php"

How is that done?
IndigoRose
 
Posts: 6
Joined: Wed Jun 29, 2011 9:41 am

Re: php and supercard-generated files

Postby johnjohnston1 » Sat Jul 02, 2011 10:59 am

IndigoRose wrote:"The other way would to be upload your data as a text file and to parse that with php"

How is that done?


I would think that is a question for a php forum. There are a ton of php resources on the web, lots more than SC!
Here is an example, remembering I know little of php
a project with a series of card 3 field on each card: name, height & shoe size
Exported to a text file data.txt with pipe characters, |, between fields and card separated by linefeed characters

in you php file where you want the list to appear:
Code: Select all
<?php
$fp = fopen("data.txt","r") ;
$ct =  fread($fp,filesize("data.txt"));
@fclose($fp);


$dataArray=explode("\n",$ct);

for ($i=0; $i < count($dataArray); $i++) {
   
   $itemarray=explode("|",$dataArray[$i]);
   
   echo "<h3>$itemarray[0]</h3> <p><strong>Height</strong>: $itemarray[1]  <strong>Shoe Size</strong>: $itemarray[2] </p>";
   # code...
}
?>

Here is a test:
http://www.littlefishsw.co.uk/test/test.php
using
http://www.littlefishsw.co.uk/test/data.txt
I'd normally put he php inside some html
BUT, imo, this is a lot less efficient than creating the webpage from SC. Each time the php page is loaded the server has to interpret the php and send html to browser.

cheers

john
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: php and supercard-generated files

Postby IndigoRose » Sun Jul 03, 2011 7:40 am

"I would think that is a question for a php forum. There are a ton of php resources on the web, lots more than SC!"

Yes, I have tried that, but I have insufficient information to bootstrap myself to the point where the php forums are of use. For instance, I was unable to get your example to work. All I got as output was:

$itemarray[0]

Height: $itemarray[1] Shoe Size: $itemarray[2]
"; } ?>

I may have something installed wrong, but I was unable to find anyone in the php forums who were familiar enough with Macs to be of assistance. I had hope that someone here might know a bit about php, so I posted it in the off-topic forum.

"BUT, imo, this is a lot less efficient than creating the webpage from SC. Each time the php page is loaded the server has to interpret the php and send html to browser."

I am unaware of a way for a webpage to request SC to generate a new webpage.
IndigoRose
 
Posts: 6
Joined: Wed Jun 29, 2011 9:41 am

Re: php and supercard-generated files

Postby Dave_Higgins » Sun Jul 03, 2011 9:01 am

IndigoRose wrote:I am unaware of a way for a webpage to request SC to generate a new webpage.

If the HTML is fairly static (won't be different on every hit), you can just have SC write the whole HTML to a file, and have the browser go to ...whatever.html
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: php and supercard-generated files

Postby IndigoRose » Sun Jul 03, 2011 9:29 am

IndigoRose wrote: "I am unaware of a way for a webpage to request SC to generate a new webpage."

"If the HTML is fairly static (won't be different on every hit), you can just have SC write the whole HTML to a file, and have the browser go to ...whatever.html"

How does a web page request that SC generate the new web page? I wasn't aware that was still possible.
IndigoRose
 
Posts: 6
Joined: Wed Jun 29, 2011 9:41 am

Re: php and supercard-generated files

Postby Dave_Higgins » Sun Jul 03, 2011 9:48 am

IndigoRose wrote:How does a web page request that SC generate the new web page? I wasn't aware that was still possible.

You can't have a web page request that SC generate it... That's why I said if it was "static" (meaning you write it once yourself (or with SC, using output from a project) and the same page is served up to anyone that comes to it).

If you're looking for "dynamic" pages (meaning that the page can/will be different every time, like a response to a form), then you're out of luck as far as that goes.

For a static page, you would write it the same as you would write any text file... Let's say you have a variable called tHTML that contains the following text:

Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<title>This is the page title.</title>
</head>
<body>

<h1>Hello there.</h1>
<p>This is my web site.</p>
</body>
</html>


You simply:

Code: Select all
put "path:to:webpages:mystuff.html" into fName
open file fName
write tHTML to file fName
close file fName


Now you set your link to go to "http://yoursite.com/mystuff.html"

You would, of course, use a more proper file path for fName and the link, but it gives the idea.
My two favorite teams are Detroit and whoever's playing Chicago.
User avatar
Dave_Higgins
 
Posts: 454
Joined: Mon Jul 07, 2008 9:50 am
Location: Dark Side Of The Moon

Re: php and supercard-generated files

Postby IndigoRose » Sun Jul 03, 2011 9:58 am

"You can't have a web page request that SC generate it."

That is why I started by asking if anyone had come across this problem, and solved it by using php. I have established that Apache is working, but I don't know why the php is not working. I have been unable to find any sites that explain how to identify what the problem may be. If I can figure that out, then the php can use the data generated by the SC project to create the web pages.
IndigoRose
 
Posts: 6
Joined: Wed Jun 29, 2011 9:41 am

Re: php and supercard-generated files

Postby johnjohnston1 » Sun Jul 03, 2011 12:09 pm

IndigoRose wrote:"You can't have a web page request that SC generate it."

That is why I started by asking if anyone had come across this problem, and solved it by using php. I have established that Apache is working, but I don't know why the php is not working. I have been unable to find any sites that explain how to identify what the problem may be. If I can figure that out, then the php can use the data generated by the SC project to create the web pages.


Hi,
I think I've picked up the wrong end of the stick, sorry.
Could you explain a little more about your whole setup?
What I've done in the past:
1. SC generates static web pages and uploads them to a server
2. SC generated text files that act like crude flat file database and uploads them to server, php parses text files.

Is your server a mac? Is SC running on the server? Have you turned php on?

cheers

John
User avatar
johnjohnston1
 
Posts: 196
Joined: Sun Jul 06, 2008 10:42 am
Location: Glasgow, UK

Re: php and supercard-generated files

Postby IndigoRose » Sun Jul 03, 2011 12:23 pm

Thank you for the help, and for keeping my frustration level down while I figured this out. I now have Apache, MySQL, and php working! It turns out that I was putting the php files in the wrong place. Off by one silly folder, and it all fell apart!

What I will be doing is having SC interpret data, and make the massaged data available to php on the server. The data will be used to create the web page. I still don't have all of the details worked out, so I don't know yet whether this will work.
Thanks again,
Indigo
IndigoRose
 
Posts: 6
Joined: Wed Jun 29, 2011 9:41 am


Return to Off Topic Lounge

Who is online

Users browsing this forum: No registered users and 1 guest