Jump to content

fetch returning "r" for results


IndianaGuy

Recommended Posts

This keeps returning odd results. I can't find much information online when I researched it.

The results are,

For testing. The IMDid is 35;
Team:r
Coach:r
Team Color:r
School:r

echo "For testing. The IMDid is " .$IMDid;
$sql4 = "SELECT * FROM reminders WHERE userFK = '$IMDid'";
                                        $result4 = mysqli_query($conn, $sql4);
                                     
                                        if (mysqli_num_rows($result4) > 0) 
                                        {
                                            while ($row4=mysqli_fetch_row($result4))
                                            {
                                                Echo "Selections:";
                                                 Echo "Team: " . row4['TeamName'];
                                                echo "<br>";
                                                Echo "Coach: " . row4['Coach'];
                                                echo "<br>";
                                                Echo "Color: " .  row4['TeamColor'];
                                                echo "<br>";
                                                Echo "School " .  row4['School'];
                                                echo "<br>";
                                              }    
                                            mysqli_free_result($result4);
	
                                        }else{
                                        echo "No record found";
                                        }              
	

 

Edited by IndianaGuy
Link to comment
Share on other sites

Place the following code as the first line of your while-statement and see what the array that you are fetching looks like.  This might give you a clue to what is going on.

print_r($row4);

Also, I am not at all sure that enclosing the value of your WHERE statement in single quotes is necessary, or even correct.

Notes from an experienced novice,

Roddy

Link to comment
Share on other sites

That is returning values by index number $row4[0], $row4[1] etc, your code asks for associated array index by textual name 'TeamName', 'Coach' etc which would use

mysqli_fetch_assoc($result4)  in while loop.

Edited by dsonesuk
  • Like 1
Link to comment
Share on other sites

I am hear you buddy. I have tried
mysqli_fetch_assoc($result4), 
mysqli_fetch_array($result4),
mysqli_fetch_row($result4).
Only so I can  at least see a different results to figure out the problem is. They all give me the same exact answer.

For testing. The IMDid is 35;
Team:r
Coach:r
Team Color:r
School:r

Edited by IndianaGuy
Link to comment
Share on other sites

1) Did you correct this and the rest of them?

row4['TeamName'];

2) when you changed to mysqli_fetch_assoc($result4), mysqli_fetch_array($result4), then mysqli_fetch_row($result4). did you change above (if corrected) to appropriate code to read from those changes? 

 

Link to comment
Share on other sites

Found a typo.
When I used fetch_row, I did change them to echo $row4[1] etc etc. I did find a typo and it works now. However, the fetch_assoc is still giving me the "r" for the results. I wish I can understand why so I can learn something. Thank you .When I did use fetch_assoc, I did change the values to $row4['School']; etc etc 

Edited by IndianaGuy
Link to comment
Share on other sites

Well I just tested it and guess what!, if you haven't corrected the code as I suggested, you get exactly that same result. Clear the History, try Ctrl F5, try another browser. Check IF php_opcache is enabled in php.ini, it caches your original page, and delays amendment showing straight away.

Edited by dsonesuk
Link to comment
Share on other sites

What he's getting at is that you left the $ off the variable names.  There's a kind of complex reason why it's printing "r", the short version is because that's the first letter of the variable name.  If you enabled all error messages you would see one for each of those lines where you try to print that.

Link to comment
Share on other sites

He had already apparently figured that out if you bothered to read his last post, SO he already GOT IT!

On 5/13/2018 at 3:30 PM, IndianaGuy said:

Found a typo.
When I used fetch_row, I did change them to echo $row4[1] etc etc. I did find a typo and it works now. However, the fetch_assoc is still giving me the "r" for the results. I wish I can understand why so I can learn something. Thank you .When I did use fetch_assoc, I did change the values to $row4['School']; etc etc  

The only reason IF he had corrected, that he would be still seeing the same results would be history or php caching still showing outdated version of the page.

Link to comment
Share on other sites

IF he was still seeing the same results, and he "GOT IT"  he had obviously "GOT IT"! from previous post pointed out! Why? basically go through repeating the same answer with "oh what he really means" condescending  reply.

IF he is seeing the same result AFTER correcting '$row' part, it must be something MORE! which is more likely to be a caching issue.

Edited by dsonesuk
Link to comment
Share on other sites

There was nothing condescending about what I said, if you took it that way it's on you, not me.  But, here we go again with you hijacking someone's topic because you have some sort of stupid beef with me.  That's kind of a pattern.  It's a whole different discussion whether he said he fixed the problem because he fixed everything he noticed but didn't notice the missing $, or if he actually fixed every problem.  I was betting on the first case.

Again, this is offtopic, and it is a non-issue.  Just move on.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...