Closed Thread Icon

Topic awaiting preservation: PHP problem.. (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=11894" title="Pages that link to Topic awaiting preservation: PHP problem.. (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP problem.. <span class="small">(Page 1 of 1)</span>\

 
sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-30-2001 22:53

Hi All,

I have this page that I'm plonking into my PHPnuke site... It lists who recently visited the site, and how long ago it was... nice feature I think.

It works fine, however, the name of the person should link to their profile page - like this -
http://mydomain.com/user.php?op=userinfo&uname=sonicsnail

but its appearing as
http://mydomain.com/user.php?op=userinfo&uname=

so it takes you to a blank page.

Now I'm no expert with PHP, but I get the feeling that theres a syntax error in this bit of the code....

$content .= "<font class=tiny><a href=\"user.php?op=userinfo&uname=\"".$uname."\">".$uname."</a>:";

Also, I think that $uname should really be $username ??

here's the whole thing... hope someone can help me here...

quote:
<?

// Michael Yarbrough
// opedog@comediccadavers.com
// http://www.comediccadavers.com/

// PHP-Nuke 5.1 Blocks version by Thiago Campos aka Mr. Hemp (mrhemp@amigoz.org)

global $cookie, $prefix, $currentlang;


if(file_exists("language/lastseen/lastseen-$currentlang.php")) {
include("language/lastseen/lastseen-$currentlang.php");
}
else {
include("language/lastseen/lastseen-english.php");
}

$numusers = 20;
$username = $cookie[1];

mysql_query("CREATE TABLE IF NOT EXISTS $prefix"._lastseen." (id INT (15) not null AUTO_INCREMENT, username TEXT not null, date INT(15) not null, ip CHAR(50), PRIMARY KEY (id), UNIQUE (id))");

if (isset($username)) {
$ip = getenv("REMOTE_HOST");
if (empty($ip)) {
$ip = getenv("REMOTE_ADDR");
}

$result = mysql_query("SELECT * FROM $prefix"._lastseen." WHERE username = \"$username\"");
if (mysql_num_rows($result) > 0) {
mysql_query("UPDATE $prefix"._lastseen." SET date = " . time() . " WHERE username = \"$username\"");
} else {
mysql_query("INSERT INTO $prefix"._lastseen." VALUES (\"\", \"$username\", ".time().", \"".$ip."\")");
}
}

$content = "";
$result = mysql_query("SELECT username, date FROM $prefix"._lastseen." ORDER BY date DESC");
while (list($uname, $date) = mysql_fetch_row($result)) {
if ($uname != $username) {
$realtime = time() - $date;
$dont = false;

// how many days ago?
if ($realtime >= (60*60*24*2)) { // if it's been more than 2 days
$days = floor($realtime / (60*60*24));
$dont = true;
} else if ($realtime >= (60*60*24)) { // if it's been less than 2 days
$days = 1;
$realtime -= (60*60*24);
}

if (!$dont) {
// how many hours ago?
if ($realtime >= (60*60)) {
//$content .= " ($realtime) ";
$hours = floor($realtime / (60*60));
$realtime -= (60*60*$hours);
}

// how many minutes ago?
if ($realtime >= 60) {
$mins = floor($realtime / 60);
$realtime -= (60*$mins);
}

// just a little precation, although I don't *think* mins will ever be 60...
if ($mins == 60) {
$mins = 0;
$hours += 1;
}
}

$content .= "<font class=tiny><a href=\"user.php?op=userinfo&uname=\"".$uname."\">".$uname."</a>:";

if ($dont) {
$content .= " ".$days." "._LASTSEENDAYS."";
} else {
if ($days > 0) {
$content .= " ".$days." "._LASTSEENDAY."".(($hours == 0 && $mins == 0)?("") ","));
}
if ($hours > 0) {
$content .= " ".$hours." ".(($hours > 1)?(""._LASTSEENHOURS."") ""._LASTSEENHOUR."")).(($mins == 0)?("") ","));
}
if ($mins > 0) {
$content .= " ".$mins." ".(($mins > 1)?(""._LASTSEENMINUTES."") ""._LASTSEENMINUTE.""))."";
} else { // less than a minute
$content .= " ".$realtime." "._LASTSEENSECONDS."";
}
}

$content .= " "._LASTSEENAGO."</font><br>";

$days = 0;
$hours = 0;
$mins = 0;
$dont = false;
}
}

$content .= "";


?>




Thanks!

::Edit to disable smilies!::



[This message has been edited by sonicsnail (edited 09-30-2001).]

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-30-2001 23:25

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 09-30-2001 23:29

Alas..

Changing -

quote:
$content .= "<font class=tiny><a href=\"user.php?op=userinfo&uname=\"".$uname."\">".$uname."</a>:";



to

quote:
$content .= "<font class=tiny><a href=\"user.php?op=userinfo&uname=".$uname."\">".$uname."</a>:";



fixed it! A "\ was the problem!

*chuffed*

Pete.


InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 09-30-2001 23:42

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 10-01-2001 00:18

Messy is a good word to describe it...

I've been tweaking lots of bits of the PHPnuke system - even REALLY simple things like the way it formats a block of text - just adding a <Br> here and there etc - but the number of times its completely screwed the site due to a syntax error on my part is a pain in the ass.

Hopefully I'll get the hang of it...

Am I right in thinking that when "echoing" html, you have to put a \ before any "'s?

Any good online resources for PHP syntax?

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-01-2001 00:28

You should escape (adding slash in front of characters is escaping) all "special" characters.

For more information about PHP syntax, take a look at PHP Manual...



[This message has been edited by mr.maX (edited 10-01-2001).]

sonicsnail
Bipolar (III) Inmate

From: Scotland
Insane since: Jun 2001

posted posted 10-01-2001 17:12

Thanks Max.

::Edit::

Any idea why my browser is trying to force me to download the the manual pages (all PHP) rather than just browsing them? (on P3, winNT, IE5). The first link I clicked worked fine, but all others are downloads now.. and even that first page is doing the same too now!!?



[This message has been edited by sonicsnail (edited 10-01-2001).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 10-02-2001 08:55

I can browse manual pages without any problems. Maybe you should try to download all pages (you have link to zip file there) and try to open them locally...

« BackwardsOnwards »

Show Forum Drop Down Menu