IndianaGuy Posted May 12, 2018 Share Posted May 12, 2018 (edited) 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 May 12, 2018 by IndianaGuy Link to comment Share on other sites More sharing options...
iwato Posted May 12, 2018 Share Posted May 12, 2018 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 More sharing options...
dsonesuk Posted May 12, 2018 Share Posted May 12, 2018 Its echo not Echo, and compare the $row4 in while loop definition, to what you are actually using, see the difference? Link to comment Share on other sites More sharing options...
IndianaGuy Posted May 12, 2018 Author Share Posted May 12, 2018 print_r is giving me the right results!! Array ( [0] => 19 [1] => 35 [2] => YES [3] => YES [4] => NO [5] => NO [6] => NO ) Not sure how the heck I got Echo instead of echo!! LOL Link to comment Share on other sites More sharing options...
dsonesuk Posted May 12, 2018 Share Posted May 12, 2018 (edited) 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 May 12, 2018 by dsonesuk 1 Link to comment Share on other sites More sharing options...
IndianaGuy Posted May 13, 2018 Author Share Posted May 13, 2018 (edited) I am hear you buddy. I have triedmysqli_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:rCoach:rTeam Color:rSchool:r Edited May 13, 2018 by IndianaGuy Link to comment Share on other sites More sharing options...
dsonesuk Posted May 13, 2018 Share Posted May 13, 2018 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 More sharing options...
IndianaGuy Posted May 13, 2018 Author Share Posted May 13, 2018 (edited) 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 May 13, 2018 by IndianaGuy Link to comment Share on other sites More sharing options...
dsonesuk Posted May 13, 2018 Share Posted May 13, 2018 (edited) 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 May 13, 2018 by dsonesuk Link to comment Share on other sites More sharing options...
justsomeguy Posted May 14, 2018 Share Posted May 14, 2018 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 More sharing options...
dsonesuk Posted May 14, 2018 Share Posted May 14, 2018 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 More sharing options...
justsomeguy Posted May 14, 2018 Share Posted May 14, 2018 I'm not going to argue with you, he said he was still seeing the same results. Pretty simple. Move on with your day. Link to comment Share on other sites More sharing options...
dsonesuk Posted May 15, 2018 Share Posted May 15, 2018 (edited) 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 May 15, 2018 by dsonesuk Link to comment Share on other sites More sharing options...
justsomeguy Posted May 15, 2018 Share Posted May 15, 2018 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now