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'; } ?> 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 ? 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)) 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()); 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)) 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. Link to comment https://forums.phpfreaks.com/topic/241065-geting-array-from-database/#findComment-1238450 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.