Aravinthan Posted August 19, 2009 Share Posted August 19, 2009 Hi, I am having problem with a very very simple code. I use it alot and it never caused me this much of trouble. Its been like 2-3 hours that I am trying to figure it out... :facewall: Ok here is the code: $result = mysql_query("SELECT * FROM history ORDER BY `id` DESC LIMIT 0,5",$link); while($row = mysql_fetch_array($result)) { $history = "" .$row['history']. ""; $playerid = substr($history, 0, 4); $getp = mysql_query("SELECT * FROM `players` WHERE `id` = '$playerid' ",$link); $player_name = mysql_fetch_array($getp) or die(mysql_error()); $Player = "" .$player_name['name']. ""; echo "$Player $history<br/>"; } ?> I echoed $playerid, alone and it shows it well... I tried running the Select sql, in PHP MyAdmin, it works.. Its only: $player_name = mysql_fetch_array($getp) or die(mysql_error()); That seems to be bugging, but I have no idea why.... Thanks, for your help, Ara Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/ Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 seems to be bugging, but I have no idea why.... Hows it bugging you ? error ? no result ? keeps tapping you on the shoulder and running away ? Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-901807 Share on other sites More sharing options...
Aravinthan Posted August 19, 2009 Author Share Posted August 19, 2009 It shows nothing... The page stops displaying after that line... Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-901808 Share on other sites More sharing options...
Aravinthan Posted August 19, 2009 Author Share Posted August 19, 2009 It works when I take that line off... It works Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-901821 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 The page stops displaying after that line... View source and check the error It works when I take that line off... It works So problem solved! Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-901827 Share on other sites More sharing options...
Aravinthan Posted August 19, 2009 Author Share Posted August 19, 2009 Yeah, but I need that line know? I mean, I need that line to get the player's name.... Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-901831 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 View source and check the error if its stopping, then the die is being called form $player_name = mysql_fetch_array($getp) or die(mysql_error()); View Source and read the last few lines you should see a SQL error Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-901848 Share on other sites More sharing options...
dirtynight Posted August 19, 2009 Share Posted August 19, 2009 Hey there, Go to the first line of your script and add the following code: <? error_reporting(E_ALL); ... . . ?> This will help you to get an idea of what went wrong. I think it is - sorry, it could be something about your myassoc-request method and your way to request the data, but i am not sure . Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-901883 Share on other sites More sharing options...
Aravinthan Posted August 19, 2009 Author Share Posted August 19, 2009 Hi, MadTechie, there is no error... The code just stops.... The rest is blank.... dirtynight, I added it but, it is still blank.... I dont know whats going wrong... I tried running the code alone on php my admin, and is able to find the data.... Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-902064 Share on other sites More sharing options...
MadTechie Posted August 19, 2009 Share Posted August 19, 2009 okay try this and report back the errors <?php $result = mysql_query("SELECT * FROM history ORDER BY `id` DESC LIMIT 0,5",$link) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $history = $row['history']; $playerid = substr($history, 0, 4); $SQL = "SELECT * FROM `players` WHERE `id` = '$playerid' "; $getp = mysql_query($SQL,$link) or die($SQL.mysql_error()); $player_name = mysql_fetch_array($getp); $Player = $player_name['name']; echo "$Player $history<br/>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-902073 Share on other sites More sharing options...
Aravinthan Posted August 19, 2009 Author Share Posted August 19, 2009 And now it works... Thanks alot, but do you know why it didnt work? Is it cuz mysql_query() was in a result itself or soemthing? Quote Link to comment https://forums.phpfreaks.com/topic/170984-solved-help-with-a-simple-code/#findComment-902101 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.