darkfreaks Posted December 30, 2008 Share Posted December 30, 2008 mysql_fetch_array not a valid MYSQL resource on line 7 code: <?php function fetch($query) { include "config.inc.php"; $result=mysql_query($query); while ($row = mysql_fetch_array($result)) {//line 7 $return = $row; } return $return; }>< Link to comment https://forums.phpfreaks.com/topic/138830-solved-function-problem/ Share on other sites More sharing options...
revraz Posted December 30, 2008 Share Posted December 30, 2008 Means your query is failing. Link to comment https://forums.phpfreaks.com/topic/138830-solved-function-problem/#findComment-725921 Share on other sites More sharing options...
darkfreaks Posted December 30, 2008 Author Share Posted December 30, 2008 the problem is this is a function designed to grab any query it takes the place of mysql_query and it arrays it too. in the function. it worked before. i dont see why its doing this :-\ Link to comment https://forums.phpfreaks.com/topic/138830-solved-function-problem/#findComment-725922 Share on other sites More sharing options...
xtopolis Posted December 30, 2008 Share Posted December 30, 2008 Means your query is failing. (not your function) Change: $result=mysql_query($query); to $result=mysql_query($query) or die(mysql_error()); to see what the error is. Link to comment https://forums.phpfreaks.com/topic/138830-solved-function-problem/#findComment-725924 Share on other sites More sharing options...
trq Posted December 30, 2008 Share Posted December 30, 2008 Indeed it does. And because you have absolutely no error handling in place you get an ugly error. <?php function fetch($query) { include "config.inc.php"; if ($result = mysql_query($query)) { if (mysql_num_rows($result) == 1) { return mysql_fetch_assoc($result); } else if (mysql_num_rows($result) > 1) { while ($row = mysql_fetch_assoc($result)) { $return[] = $row; } return $return; } return false; } } Link to comment https://forums.phpfreaks.com/topic/138830-solved-function-problem/#findComment-725925 Share on other sites More sharing options...
darkfreaks Posted December 30, 2008 Author Share Posted December 30, 2008 nevermind SOLVED! Link to comment https://forums.phpfreaks.com/topic/138830-solved-function-problem/#findComment-725933 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.