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>';
    }
?>
6
  • What do you expect it to do? And what do you mean "but it just will not work", you need to describe that better. How does it not work? Commented May 15, 2015 at 2:41
  • It doesn't work as in nothing happens, but in phpmyadmin, the script(select query) is working fine. i expect to show the data from the database. Commented May 15, 2015 at 2:58
  • So, does $username have a value? Why don't you echo it out before you run your query and show us what the return is. Commented May 15, 2015 at 2:59
  • yes it has a value, i did echo 'test'; and it worked Commented May 15, 2015 at 3:02
  • I meant do echo $username.... Commented May 15, 2015 at 3:03

2 Answers 2

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');
Sign up to request clarification or add additional context in comments.

3 Comments

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?
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: stackoverflow.com/questions/13640109/…
the other thing i posted about new data is different from the question sorry about that.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.