Uutiset:

Join the Facebook Fan Page.

Main Menu
Advertisement:

Site query to DB?

Aloittaja ziycon, tammikuu 11, 2006, 11:41:59 AP

« edellinen - seuraava »

ziycon

Ive searched and cant find it.
But does anyone know how to query the database from a website to publish a list of users online in the chat forum onto a php website????

Leipe Po

http://www.simplemachines.org/community/ssi_examples.php

try taking a look there, think its ssi_logonline() and/or ssi_usersonline or somthing
There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

ziycon

i found it on that page thanks, i need to add this to my php page:

<?php require("SSI.php"); ?>

say that file is kept some were like here:

www.domainname.com/forum/SSI.php

how do i referance it?

ziycon

I have referanced in such a way that i get a message at top of the site:

Please don't access SSI.php by URL directly; you may want to use the path ('SSI.php') or add ?ssi_function=something.

Can anyone help with this please?

Leipe Po

wel if you use header and footer, open your header and add at the verry first line!!!
<?php require("forum/SSI.php"); ?>

if not, you will have to add that code above to every file you want to use ssi on

and then where you want the online list to show up:
<?php ssi_whosOnline(); ?>

or if you also want them logged:
<?php ssi_logOnline(); ?>

Greetz Leipe_Po

There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

ziycon

i've done that, when i open the page i get thie error below, the website is in a folder called html and smf is in a folder called forum, these to folders are in the same directory as eachother.

Warning: main(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/index1.php on line 118

Warning: main(http://forum/SSI.php?ssi_whosOnline()): failed to open stream: Address family not supported by protocol in /var/www/html/index1.php on line 118

Warning: main(): Failed opening 'http://forum/SSI.php?ssi_whosOnline()' for inclusion (include_path='.:/php/includes:/usr/share/php') in /var/www/html/index1.php on line 118

Any ideas?

ziycon

I fixed the first errors there but now i have these two errors, any idea hw i get around them? i need to access the SSI.php file from

\var\www\forum\

but the the website is kept in

\var\www\html\

Here are the errors:

Warning: main(/SSI.php?ssi_whosOnline()): failed to open stream: No such file or directory in /var/www/html/index1.php on line 118

Warning: main(): Failed opening '/SSI.php?ssi_whosOnline()' for inclusion (include_path='.:/php/includes:/usr/share/php') in /var/www/html/index1.php on line 118

Leipe Po

that means your path is wrong, try
<?php require("./forum/SSI.php"); ?>
or
<?php require("../forum/SSI.php"); ?>
There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

ziycon

no, it didnt work, that would only bring me back to

\var\www

Leipe Po

hmmz interesting.....
the ../ part should bring you back to WWW and then the forum/ part should send you to the ssi file so i'm riddled,
could you do a test for me?

create a file(any name) in you WWW folder and use:

<?php require("forum/SSI.php"); ?>

<?php ssi_logOnline(); ?>


also try playing with the url like:
<?php require("/forum/SSI.php"); ?>
<?php require("/../forum/SSI.php"); ?>
<?php require("/./forum/SSI.php"); ?>
There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

ziycon

i fixed that and got it working. Thank you for all your help.

One last question, how do i put this line into the site:

?ssi_whosOnline()

Leipe Po

<?php ssi_whosOnline(); ?>
this should work fine, ssi has it all tuckt away in function so
There is only one thing more importend to me then coding:
My Girlfriend

Microsoft - "You've got questions.  We've got dancing paperclips."

newy

I know this is an old post but its all i could find about it using the searc..

Im getting this same error:  Im trying to call the functions into my site to display the recent posts on my homepage..  The forum is on a sub.domain so i make the call:

<?php require("http://forum.mysite.com/SSI.php [nofollow]"); ?>
&/or
<?php include("http://forum.mysite.com/SSI.php [nofollow]"); ?>


& using : <?php ssi_recentPosts(); ?>

But get this error:

Please don't access SSI.php by URL directly; you may want to use the path ('SSI.php') or add ?ssi_function=something

basically saying not to use direct paths.. How else am i supposed to call it from a sub.domain if not using direct paths ?


Can anyone help with this as its getting rather frustrating :(

regards

newy

Daniel15

LainaaBut get this error:

Please don't access SSI.php by URL directly; you may want to use the path ('SSI.php') or add ?ssi_function=something

basically saying not to use direct paths.. How else am i supposed to call it from a sub.domain if not using direct paths ?
Just like the error says, use ssi_function=something. Using http://forum.mysite.com/SSI.php?ssi_function=recentPosts should work.

Note that even though it's on a subdomain, you should still be able to access SSI.php via its file path (as long as the site is on the same server). Something like:

require('/home/username/public_html/forum/SSI.php');

Should work, and this gives you more flexibility (including SSI functions via URL doesn't allow you to customise how the output is formatted, whereas with the PHP ones, you can get the raw data and output it yourself :))
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

newy


Hi daniel..  Thanks for your reply !.. i only just got too it today..  I managed to output the data.. but how do i customise it ?

I pressumed i could just "Style" a Div but that doesnt take effect ... Where and how can i Style the Output it gives me ? .. It looks pretty horrible at the moment ..

Is there a way of getting rid of the dates on it aswell ?

reghards

newy

Daniel15

To change how the data is output, you'd need to access SSI.php directly, by its file path.

At the top of the page, put this:

<?php
require('forum/SSI.php');
?>



Where you'd like the data to appear, put this:

<?php
// Get the recent posts
$posts ssi_recentPosts(8null'array'); // 8 = number of posts to display

// Loop through all of them
echo '
<table border="0" class="ssi_table">'
;
foreach (
$posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
['
$post['board']['link'], ']
</td>
<td valign="top">
<a href="'
$post['href'], '">'$post['subject'], '</a>
'
$txt[525], ' '$post['poster']['link'], '
'
$post['new'] ? '' '<a href="' $scripturl '?topic=' $post['topic'] . '.msg' $post['new_from'] . ';topicseen#new"><img src="' $settings['images_url'] . '/' $context['user']['language'] . '/new.gif" alt="' $txt[302] . '" border="0" /></a>''
</td>
<td align="right" nowrap="nowrap">
'
$post['time'], '
</td>
</tr>'
;
echo 
'
</table>'
;
?>



The "array" ssi_recentPosts output method returns all the data in a raw form, and then we output it via our code. This allows you to customise how it's displayed. Note that my code is the exact same code used by default. You may customise this as much as you want (eg. if you don't want to use a table, and instead just want to display a list).

To get rid of the date, remove this bit from the code:

<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

newy

#16
Ok i have no idea what is going on!  If i use the following code below:


<?php
require('forum/SSI.php');
?>



and alter the path forum/SSI.php  to my own file path  http://forum.mysite.blah/SSI.php  I get an error telling me to use the ssi_function=somthing

If i use the ssi_function=somthing  it displays the recent posts albeit at the top of my page (obviously)... But if i use that same ss-_function in the centre of my page where i want the output displayed, i have no control over customisation..

The code below  when used gives me error: Fatal error: Call to undefined function: ssi_recentposts()
SO no matter what combination or whatever i use all this. non of it is working..



<?php
// Get the recent posts
$posts ssi_recentPosts(8null'array'); // 8 = number of posts to display

// Loop through all of them
echo '
<table border="0" class="ssi_table">'
;
foreach (
$posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
['
$post['board']['link'], ']
</td>
<td valign="top">
<a href="'
$post['href'], '">'$post['subject'], '</a>
'
$txt[525], ' '$post['poster']['link'], '
'
$post['new'] ? '' '<a href="' $scripturl '?topic=' $post['topic'] . '.msg' $post['new_from'] . ';topicseen#new"><img src="' $settings['images_url'] . '/' $context['user']['language'] . '/new.gif" alt="' $txt[302] . '" border="0" /></a>''
</td>
<td align="right" nowrap="nowrap">
'
$post['time'], '
</td>
</tr>'
;
echo 
'
</table>'
;
?>




<td align="right" nowrap="nowrap">
', $post['time'], '
</td>


Edited by Daniel15: Fixed formatting

Daniel15

Do not use the URL for the SSI.php file, use the path to the file ;).
Go to your forum's admin panel, and click on the "Server Settings" link. Your forum's directory will be listed under "SMF Directory". Change the require(...) line to include this path with SSI.php appended to it.
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

newy


Many thanks Daniel !...

Very much appreciated  :)  -  Its a good job somebody knows what their doing :D

Daniel15

No problem ;)
If you have any further questions, please feel free to ask :)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Advertisement: