1

I was working on a wallpost script, the page has no errors, i've check with the database (the query worked there) and i've tried everything i think i can, but it just will not work. I don't know what else to do, if you have any ideas to why it won't work, show me. PS: the database has some dummy data in it.

<?php
    include 'inc/dbc.php';
    include 'inc/functions.php';

    if(isset($_GET['user']) && !empty($_GET['user'])) {
        $username = $_GET['user'];
    } else {
        $username = $_SESSION['username'];
    }

    $my_name = $_SESSION['username'];
    $firstname = getuser($username, 'firstname');
    $middlename = getuser($username, 'middlename');
    $lastname = getuser($username, 'lastname');
    $aboutme = getuser($username, 'aboutme');
    $email = getuser($username, 'email');
    $dob = getuser($username, 'dob');
    $address = getuser($username, 'address');
    $website = getuser($username, 'website');
    $country = getuser($username, 'country');
    $city = getuser($username, 'city');
    $state = getuser($username, 'state');
    $phone = getuser($username, 'phone');
    $gender = getuser($username, 'gender');
    $rank = getuser($username, 'rank');
    $avatar = getuser($username, 'avatar');
    $reg_date = getuser($username, 'reg_date');
?>
<?php
    if (loggedIn() == true) {
        $chech_posts = mysqli_query($mysqli, "SELECT * FROM wallposts WHERE posted_to = '$username' AND deleted = 0 ");
        $check = mysqli_num_rows($chech_posts);

        if ($check == false) {
            echo '<li>Error Getting posts</li>';
        } else {
            while ($run = mysqli_fetch_array($check)) {
                $post_id = $run['post_id'];
                $postby = $run['posted_by'];
                $postto = $run['posted_to'];
                $post = $run['post'];
                $post_date = $run['post_date'];
                $post_time = $run['post_time'];

                $p_avatar = getuser($postby, 'avatar');
                $p_first = getuser($postby, 'firstname');
                $p_last = getuser($postby, 'lastname');
?>
    <li class='wall' id='<?php echo $post_id;?>'>
        <div class='post'>
            <div class='post-container'>
                <div class='post-header'>
                    <div class='pull-left'><?php echo $postby;?></div>
                    <div class='post-img'><img src="images/users/<?php echo $p_avatar;?>" alt="<?php echo $p_first . ' ' . $p_last  . '\'s Profile Picture' ;?>" class="img-circle" align="middle"></div>
                    <div class='pull-right'><?php echo $post_date?></div>
                </div>
                <div class='post-body'>
                    <p><?php echo $post;?></p>
                </div>
                <div class='post-footer'>
                    <div class='lk-cmt-shr'>
                    </div>
                    <span id='comments'>

                    </span>
                </div>
            </div>
        </div>
    </li>
<?php
            }
        }

    } else {
        echo '<li>You must be <a href="index.php">logged</a> in to view ' . $firstname . '\'s posts.</li>';
    }
?>

2 Answers2

2

Lets add after <?php these 2 lines and refresh the page. It can highlight the error.

error_reporting(E_ALL);
ini_set('display_errors','On');
Axalix
  • 2,831
  • 1
  • 20
  • 37
  • Thanks but the page is still error free and the data is not showing, also for some reason why i change a single word or element or anything in my html or php script the page doesn't show the new data when i reload the page till after a certain time, do you know the problem why? – Clement Abel May 15 '15 at 02:31
  • I am a bit confused now, because in your original question you said "not showing any data" and in your comment your said "doesn't show the new data when i reload the page till after a certain time". If the script works and there are no errors, the reason why you have to reload the page is browser's cache. You can play with headers from this post to solve the issue: http://stackoverflow.com/questions/13640109/how-to-prevent-browser-cache-for-php-site – Axalix May 15 '15 at 02:42
  • the other thing i posted about new data is different from the question sorry about that. – Clement Abel May 15 '15 at 02:55
0

I finally got it to work, but i do not know why this was a problem/solution, but if you do, please explain it to me. Anyway, to fix my issue i took out the second if statement and just used the while loop instead. I hope this makes sense. Thank you all for your help though :D.