2006-01-17, 12:24 AM
Pages: 1 2
2006-01-17, 01:09 AM
The easiest way that I can think of is if you include the global.php file.
chdir("forum"); // path to MyBB
require "./global.php";
echo $mybb->user['username'];
Or you can create your own mysql query and then display the username that way. 2006-01-17, 10:56 AM
Thanx for your help.
By using your code I get
Any idea???
By using your code I get
Fatal error: Call to a member function on a non-object in /var/www/forum/inc/class_datacache.php on line 33
Any idea???
2006-01-17, 11:46 AM
heloo there
please make a new php file
and put this code in
$user is a variable so put it in a template or in the page.
however u may use the ECHO in case ur just running the php file without templates
regards
please make a new php file
and put this code in
<?php
// hostname or ip of server
$servername='localhost';
// username and password to log onto db server
$dbusername='prefix_user';
$dbpassword='pass';
// name of database
$dbname='prefix_database';
////////////// Do not edit below/////////
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
///////////////////////////Now to show the usernames
///////u may edit here , the way u want it, it's just an example, it's just the above code that;s used to connect
$rt = $db->query("SELECT uid, username FROM `easyflas_users`);
while($nt = $db->fetch_array($rt)){
$user = "<a href=\"member.php?action=profile&uid=$nt[uid]\">$usr</a>";
}
$user is a variable so put it in a template or in the page.
however u may use the ECHO in case ur just running the php file without templates
echo "$nt[username]";
regards
2006-01-18, 12:14 AM
Hey, I tried it:
On a empty page I get this error
Line 26 is:
If I comment
The page is complete empty
Using the same in my script I get
line 46 is
I am sure I used the correct settings for the db. Any ideas?
On a empty page I get this error
Parse error: parse error, unexpected T_STRING in /var/www/forum/test.php on line 26
Line 26 is:
$user = "<a href="member.php?action=profile&uid=$nt[uid]\">$usr</a>";
If I comment
$rt = $db->query("SELECT uid, username FROM `easyflas_users`);
while($nt = $db->fetch_array($rt)){
$user = "<a href="member.php?action=profile&uid=$nt[uid]\">$usr</a>";
out and useecho "$nt[username]";
The page is complete empty
Using the same in my script I get
Fatal error: Call to undefined function: connecttodb() in /var/www/forum/comment_functions.php on line 46
line 46 is
connecttodb($servername,$dbname,$dbusername,$dbpassword);
I am sure I used the correct settings for the db. Any ideas?
2006-01-18, 12:38 AM
zaher1988 forgot to escape a double quote.
$user = "<a href=\"member.php?action=profile&uid=$nt[uid]\">$usr</a>";
2006-01-18, 02:01 AM
He also forgot to escape a double quote here
But I still get
in the empty file
and/or
in my script
$rt = $db->query("SELECT uid, username FROM `easyflas_users`");
But I still get
Fatal error: Call to a member function on a non-object in /var/www/forum/test.php on line 24
in the empty file
and/or
Fatal error: Call to undefined function: connecttodb() in /var/www/forum/comment_functions.php on line 46
in my script
2006-01-18, 03:20 AM
well $db->query should be mysql_query and $db->fetch_array should be mysql_fetch_array
2006-01-18, 03:39 PM
Now I get
I put the test.php file as an attachment. I hope this not the fault of the server
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/forum/test.php on line 25
I put the test.php file as an attachment. I hope this not the fault of the server
2006-01-18, 04:10 PM
Pages: 1 2