03-20-2017, 08:02 AM
Hello!
I have recently started using UserSpice and I think it's awesome so far! I've never experienced working with a framework this uncomplicated. So cred to the developers, keep up te good work
I have run into a slight problem, and I've been looking around on the web and on this forum, and in the documentation, but haven't found exactly what i'm looking for. Being inexperienced with PHP doesn't help either.
So I thought i'd give it a shot asking you guys
Here goes:
I have a page, let's called it mypage.php
On that page, I have included a php file. Let's call it include1.php.
It is reloaded every second using a piece of javascript. Like this:
<pre></pre>
That document has a list of other php files included. Let's call one of them include2.php.
It stems out like a tree, but my question is regarding what is suppose to happen inside include2.php.
The code in there looks like this:
<pre></pre>
So the idea here is that include2.php will get text from a URL that is different for each user, depending on what is stored in "MyOwnColumn", that I have added to the database. There is only plain text on the URL which file_get_contents will read.
I have tried this:
<pre></pre>
And it works fine. I found "$user->data()->MyOwnColumn" in the UserSpice account.php file and tried it. I'm not sure if this is it's correct usage? I only altered the column to fit my own needs.
I have also tried the following, and it works fine with the piece of javascript reloading it:
<pre></pre>
I have also tried this, but WITHOUT javascript, only
<pre></pre>
And that works fine.
So the problem here seems to be, that when I use javascript to reload the included php files, it won't accept that I have put $my_url in the url which file_get_contents will "read".
The reason why I am asking here and not stackoverflow for example, is that I am not really sure how to correctly fetch data from the db in userspice. I know there is documentation on that, but I don't want to fetch everything in a table, but only from the logged in user. And that's where my knowledge of PHP limits me.
I hope I haven't been too confusing, but feel free to ask questions if I have
Best regards!
`
I have recently started using UserSpice and I think it's awesome so far! I've never experienced working with a framework this uncomplicated. So cred to the developers, keep up te good work
I have run into a slight problem, and I've been looking around on the web and on this forum, and in the documentation, but haven't found exactly what i'm looking for. Being inexperienced with PHP doesn't help either.
So I thought i'd give it a shot asking you guys
Here goes:
I have a page, let's called it mypage.php
On that page, I have included a php file. Let's call it include1.php.
It is reloaded every second using a piece of javascript. Like this:
<pre>
Code:
<div class="View"></div>
<script>
setInterval(function(){
$.ajax({
url: "include1.php",
cache: false,
success: function(html){
$(".View").html(html);
},
});
},1000);
</script>
That document has a list of other php files included. Let's call one of them include2.php.
It stems out like a tree, but my question is regarding what is suppose to happen inside include2.php.
The code in there looks like this:
<pre>
Code:
<?php
$my_url = 'http://awebsite.com/'.$user->data()->MyOwnColumn.'/other/stuff';
$test_var = file_get_contents($my_url, NULL, NULL, 5, 2);
echo $test_var;
if ($test_var === "Hi") {
echo '
Success!';
}
?>
So the idea here is that include2.php will get text from a URL that is different for each user, depending on what is stored in "MyOwnColumn", that I have added to the database. There is only plain text on the URL which file_get_contents will read.
I have tried this:
<pre>
Code:
$my_url = 'http://awebsite.com/'.$user->data()->MyOwnColumn.'/other/stuff';
echo $my_url;
And it works fine. I found "$user->data()->MyOwnColumn" in the UserSpice account.php file and tried it. I'm not sure if this is it's correct usage? I only altered the column to fit my own needs.
I have also tried the following, and it works fine with the piece of javascript reloading it:
<pre>
Code:
$test_var = file_get_contents('http://awebsite.com/in/plain/text', NULL, NULL, 5, 2);
echo $test_var;
I have also tried this, but WITHOUT javascript, only
Code:
<?php include 'include1.php'; ?>
<pre>
Code:
$test_var = file_get_contents('http://awebsite.com/'.$user->data()->MyOwnColumn.'/other/stuff', NULL, NULL, 5, 2);
echo $test_var;
And that works fine.
So the problem here seems to be, that when I use javascript to reload the included php files, it won't accept that I have put $my_url in the url which file_get_contents will "read".
The reason why I am asking here and not stackoverflow for example, is that I am not really sure how to correctly fetch data from the db in userspice. I know there is documentation on that, but I don't want to fetch everything in a table, but only from the logged in user. And that's where my knowledge of PHP limits me.
I hope I haven't been too confusing, but feel free to ask questions if I have
Best regards!
`