Jump to content

MySQL query select


Kraven

Recommended Posts

I'm having some difficulty with a 3rd party private messaging script.

When I compose a message, the data goes into the dbtable, but I can't get it to display on the page using a query.

I've looked over this code so many times I'm getting double vision, and I can't see what's wrong.

There are 2 tables. One is members, which is where the pm_count is. And the other is messages, where the message itself goes.

The info is there, it just doesn't display.

No error messages. It says  of 50 Total | 0% full.

Here's the section of code that handles that function. The include at the top makes the db connection. That works fine.

If anyone can spot the problem, please let me know... Thanks.

<?php
    session_start();
    $user = $_SESSION['login'];
    
    include 'db.php';
        
    //This checks to see if a user is logged in or not by seeing if the sessioned username varialble exists.
    //You could change this check to however you want to validate your members, this is just how I did it.
    if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
	header("location: http://www.mysite.com/pmmessage/phploginnew/access-denied.php");
        }
    
    else
        {
        //Query the database to see how many messages the logged in user has, then do a little math
        //Find the percentage that your inbox is full (message count divided by 50)
        //50 messages maximum, you can change that
        $sql = mysql_query ("SELECT pm_count FROM members WHERE login='$user'");
        $row = mysql_fetch_array ($sql);
        $pm_count = $row['pm_count'];
        
        //This is the math to figure out the percentage.
        //The message could divided by 50 then multiplied by 100 so we dont have a number less than 1
        $percent = $pm_count/'50';
        $percent = $percent * '100';
        
        //Next we come out of PHP and show some HTML, the inbox fullness, links to the other message system pages, the messages, etc.
        ?>
        <br>
        <center>
        <b><p><a href="http://www.mysite.com/pmmessage/phploginnew/inbox.php">Inbox</a> | <a href="http://www.mysite.com/pmmessage/phploginnew/compose.php">Compose</a> | <a href="http://www.mysite.com/pmmessage/phploginnew/sent.php">Sentbox</a></b>
        <b><p><?php echo "$pm_count"." of 50 Total  |  "."$percent"."% full"; ?></p></b>
        </center>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.