Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6348515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:26:03+00:00 2026-05-24T21:26:03+00:00

<h2>User Profile: <?php if($sth->rowCount() > 0) {$row = $sth->fetch(PDO::FETCH_ASSOC);echo &nbsp;{$row[‘uname’]};} else {echo No data.;}?></h2>

  • 0
        <h2>User Profile: <?php if($sth->rowCount() > 0) {$row = $sth->fetch(PDO::FETCH_ASSOC);echo "&nbsp;{$row['uname']}";} else {echo "No data.";}?></h2>
        <span class="two">Registered Date: <?php if($sth->rowCount() > 0) {$row = $sth->fetch(PDO::FETCH_ASSOC);echo "&nbsp;{$row['regDate']}";} else {echo "No data.";}?> </span><br />
        <span class="three">Current Grade: <?php if($sth->rowCount() > 0) {$row = $sth->fetch(PDO::FETCH_ASSOC);echo "&nbsp;{$row['currGrade']}";} else {echo "No data.";}unset($sth);?> </span><br />

Error I get: Fatal error: Call to a member function rowCount() on line 30

Line 30 is:

    <span class="three">Current Grade: <?php if($sth->rowCount() > 0) {$row = $sth->fetch(PDO::FETCH_ASSOC);echo "&nbsp;{$row['currGrade']}";} else {echo "No data.";}unset($sth);?> </span><br />

SQL behind the scenes:

#Get Student Info :: for Page Content
$pdo = new PDO('mysql:host=localhost;dbname=ureviewdu', $u, $p);
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth = $pdo->prepare('
    SELECT uname, currGrade, regDate
    FROM Student
    WHERE usrID = ?;
    ;');
$sth->execute(array(
    $userID
));

This updated code yields nothing for each query… why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:26:04+00:00Added an answer on May 24, 2026 at 9:26 pm

    You’re unsetting the PDOStatement $sth variable at the end of each block. You won’t be able to use it after unsetting it.

    You should probably just create one logical branch based on the result of the fetch, eg

    <?php if ($row = $sth->fetch(PDO::FETCH_ASSOC)) : ?>
    <h2>User Profile: <?php echo htmlspecialchars($row['uname']) ?></h2>
    <span class="two">Registered Date: <?php echo htmlspecialchars($row['regDate']) ?></span><br />
    <span class="three">Current Grade: <?php echo htmlspecialchars($row['currGrade']) ?></span><br />
    <?php $sth->closeCursor(); else : ?>
    <h2>User Profile: No data.</h2>
    <span class="two">Registered Date: No Data.</span><br />
    <span class="three">Current Grade: No Data.</span><br />
    <?php endif ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

RewriteRule ^user/(.*)/(.*) profile.php?user=$1&v=$2 [L] works for http://10.0.1.5/user/Kevin/wall/ if i do http://10.0.1.5/user/Kevin/wall it 404's. if
Why isn't this working? I'm trying to make a php user profile URL. <?php
I have a database situation where I'd like to get a user profile row
How would I rewrite: http://localhost/profile.php?user=MaFi to http://localhost/user/MaFi
I have an user id: 503536350 , this is the profile: https://www.facebook.com/profile.php?id=503536350 but why
Currently I'm building a system (php and mysql), that on the user profile allows
I want that every user has a profile-url like this: www.example.com/username But my php
I'm writing a PHP script that retrieves steam user profile information (for a servers
I have been using a custom template file called user-profile.tpl.php for a while. But
Lets say, user go to profile.php page, but it requires login. Then it redirects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.