We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm looking at getting a csv into Processing.js via php, but I'm having a bit of trouble with the concept.
I think I am meant to make a variable in php and echo it.
// php
$csv = array();
Loading and parsing code for csv
echo $csv;
Then I can use loadStrings() in Processing.js to bring it in?
// processing.js
csvLines = loadStrings("//localhost/myFolder/Script.php?csv");
The Quick and Dirty and Schiffman examples are slightly more advanced and use load and save states, but should the above work in principle?
Otherwise, what is the way to access php variables in processing? Google groups states the below, but it makes no sense to me;
void setup(){}
void draw(){
<?php echo $var; ?>
<?=$var2?>
}
Thanks for any guidance.
Answers
"//localhost/myFolder/Script.php?csv"
The URL seems bad. Should be a single initial slash, or should be prefixed with
http:
Sorry PhiLho,
I did not give you all the information...:) I'm using Wamp, so the //localhost works ok
I managed to get it all working when I followed the Schiffman php persistence example a bit more closely....
my issue was confusion over the concept that I could not (from processing) load the values of a variable from within a php script, instead I had to send a query and that combined with the php echoing content, seems to be the way to get it out.
Unless there is an easier way to grab the values in a php defined variable more directly? I saw some talk of a global js variable defined in canvas, html, ....or something.... that was accessible, but none of it seems clear, not like processing :)
Thanks PhiLho, if you have any insight on the variable access, please do let me know.
All the best....
"I had to send a query and that combined with the php echoing content"
Yes, it should be this way. Actually, I cannot imagine another way...
Nice, thanks.
Just getting my head around php's 'personality' :)
Thanks you sir!