TheSky Posted July 4, 2011 Share Posted July 4, 2011 i wanted to get array from database but im making somthing wrong have been using google and thinking about 2 days what im doing wrong.. help would be more then welcome thanks. <? include('connectx.php'); $name = htmlspecialchars($_GET['id']); $sqlll="SELECT * FROM data WHERE user='$name'"; $resultss=mysql_query($sqlll); if(mysql_num_rows($resultss)>0) { while($row=mysql_fetch_array($sqlll)) { $row=unserialize($row['items']); foreach($row as $item) { print $item.'</ br>'; } } } else { print 'Seems there is no data'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/241065-geting-array-from-database/ Share on other sites More sharing options...
TeNDoLLA Posted July 4, 2011 Share Posted July 4, 2011 Have you tried to var_dump, echo or debug the variables in the different stage of your script, do they have expected values or not ? And also do you have error reporting on ? Quote Link to comment https://forums.phpfreaks.com/topic/241065-geting-array-from-database/#findComment-1238231 Share on other sites More sharing options...
TheSky Posted July 4, 2011 Author Share Posted July 4, 2011 yes i have Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a9953296/public_html/index.php on line 25 line 25 while($row=mysql_fetch_array($sqlll)) Quote Link to comment https://forums.phpfreaks.com/topic/241065-geting-array-from-database/#findComment-1238234 Share on other sites More sharing options...
TeNDoLLA Posted July 4, 2011 Share Posted July 4, 2011 So your SQL query is failing. Echo out this $sqlll variable and see if its correct query you are building there. Also you can add this to the query, so you get some mysql error if one exists: $resultss=mysql_query($sqlll) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/241065-geting-array-from-database/#findComment-1238237 Share on other sites More sharing options...
Andrew777 Posted July 4, 2011 Share Posted July 4, 2011 i believe your calling the wrong variable in this line... while($row=mysql_fetch_array($sqlll)) i think it should be......... while($row=mysql_fetch_array($resultss)) Quote Link to comment https://forums.phpfreaks.com/topic/241065-geting-array-from-database/#findComment-1238378 Share on other sites More sharing options...
TeNDoLLA Posted July 5, 2011 Share Posted July 5, 2011 Indeed, thats true. Missed that one. Quote Link to comment https://forums.phpfreaks.com/topic/241065-geting-array-from-database/#findComment-1238450 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.