Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-12-2005, 08:50 PM Annoying PHP issues
Junior Talker

Posts: 1
Trades: 0
Ok, at this point I am going crazy. Im trying to write a CMS/Forum Integration thing, and I just got stopped in my tracks. I havn't done anything forum integration-y yet, just writing the stand alone software. First off, the system as a whole was working, then I tried adding a script called article.php

Code:
<?
include('dbconnect.php');
//Get the article title
    function article_title ()
{
$gettitlequery = mysql_query("SELECT title FROM article WHERE id='$id'");
$fetchtitle = @mysql_fetch_object($gettitlequery);
$fetchtitle = ucfirst(strtolower($fetchtitle));
echo("$fetchtitle");
}
?>
The idea is obvious enough, I call the article title from the database using an id in the URL (IE ?id=XX) and it prints the article on the page. When I call the function from the main page, nothing shows up. Then, after a little while, my users online script stopped printing data.

Code:
 <?php
include('dbconnect.php');
// set some variables first
$timeoutseconds = 180;  // seconds for the timeout period

//get the time
$timestamp = time();         // get current time
$timeout = $timestamp-$timeoutseconds;
$ip = $_SERVER['REMOTE_ADDR'];
$file = $_SERVER['PHP_SELF'];
$member = $_COOKIE['member'];    // replace with login cookie name

// insert into database
if (!empty($member))
{
    $qInsert = "INSERT into useronline (timestamp, ip, file, name) VALUES ('$timestamp','$ip','$file','$member') ";
}
else
{
    $qInsert = "INSERT into useronline (timestamp, ip, file, name) VALUES ('$timestamp','$ip','$file','') ";
}
    $rsInsert = mysql_query($qInsert);

// now delete old timeout records from the database
$delete = mysql_query("DELETE FROM useronline WHERE timestamp<$timeout");

// now optimize the database
$optimize = mysql_query("OPTIMIZE TABLE `useronline` ");

// now for the display, get the records from the database.
// =========================================
// first get the members records
$mresult = mysql_query("SELECT distinct name FROM useronline WHERE file='$file' and name !='' ");
// now get the non-members records
$result = mysql_query("SELECT distinct ip FROM useronline WHERE file='$file' and name !='' ");

@$user = mysql_num_rows($result);
@$muser = mysql_num_rows($mresult);

// now we display the results
if ($user != 1)
{
    echo $user.' <b>guests</b> online</br>';
}
else
{    echo $user.' <b>guest</b> online</br>';        }    // for grammar

if ($muser != 1)
{
    echo $muser.' <b>users</b> online</br>';
}
else
{    echo $muser.' <b>user</b> online</br>';        } // for grammar

// now get the link to the profile for members online
$comma_flag = 0;
while ($row = mysql_fetch_array($mresult))
{
    extract($row);
    if (!$comma_flag)
        $comma_flag = 1;
    else
        echo ', ';

    $qLink = "select id from member_profile where username='$name' ";
    $rsLink = mysql_query($qLink);
    $linkrow = @mysql_fetch_array($rsLink);
    extract($linkrow);

    // display the list of members online
    echo '<b>»</b> <a href="viewprofile.php?id='.$id.'">'.$name.'</a>';
}
?>
It used to show numbers, then it stopped. Any help I can get on either of these issues would be awesome. There are no error messages associated with either one of these scripts BTW.
zeshon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Annoying PHP issues
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46007 seconds with 12 queries