GM Revan Posted September 7, 2011 Share Posted September 7, 2011 Full error: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\MyWebsite\poll\functions.php on line 28 Been working all day to set up some stuff in my website. Now currently working on the poll. Been stuck on this error and I don't know what to do. That's the function that throws this: Any help would be appreciated. function getPoll($pollID){ $query = "SELECT * FROM polls LEFT JOIN pollAnswers ON polls.pollID = pollAnswers.pollID WHERE polls.pollID = " . $pollID . " ORDER By pollAnswerListing ASC"; $result = mysql_query($query); //echo $query;jquery $pollStartHtml = ''; $pollAnswersHtml = ''; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $pollQuestion = $row['pollQuestion']; $pollAnswerID = $row['pollAnswerID']; $pollAnswerValue = $row['pollAnswerValue']; if ($pollStartHtml == '') { $pollStartHtml = '<div id="pollWrap"><form name="pollForm" method="post" action="poll/functions.php?action=vote"><h3>' . $pollQuestion .'</h3><ul>'; $pollEndHtml = '</ul><input type="submit" name="pollSubmit" id="pollSubmit" value="Vote" /> <span id="pollMessage"></span></form><>'; } $pollAnswersHtml = $pollAnswersHtml . '<li><input name="pollAnswerID" id="pollRadioButton' . $pollAnswerID . '" type="radio" value="' . $pollAnswerID . '" /> ' . $pollAnswerValue .'<span id="pollAnswer' . $pollAnswerID . '"></span></li>'; $pollAnswersHtml = $pollAnswersHtml . '<li class="pollChart pollChart' . $pollAnswerID . '"></li>'; } echo $pollStartHtml . $pollAnswersHtml . $pollEndHtml; } Quote Link to comment https://forums.phpfreaks.com/topic/246647-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/ Share on other sites More sharing options...
Maq Posted September 7, 2011 Share Posted September 7, 2011 Query is probably failing returning false. Use mysql_error() to see what the error is. Quote Link to comment https://forums.phpfreaks.com/topic/246647-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1266515 Share on other sites More sharing options...
GM Revan Posted September 8, 2011 Author Share Posted September 8, 2011 Query is probably failing returning false. Use mysql_error() to see what the error is. Yes tnx I actually found that I couldn't connect or select the database. The include files of my db connect didn't work on just functions.php for some strange reason. So I put the entire mysql_connect and mysql_select for it to actually make them work.Whats up with the include not working? The path is the same as the other files at similar locations but no matter how I change the path it throws me this errors (if I use the include functions): Warning: include(../func/config.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\MyWebsite\poll\functions.php on line 6 Warning: include() [function.include]: Failed opening '../func/config.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\MyWebsite\poll\functions.php on line 6 Warning: include(../func/init.php) [function.include]: failed to open stream: No such file or directory in C:\xampp\htdocs\MyWebsite\poll\functions.php on line 8 Warning: include() [function.include]: Failed opening '../func/init.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\MyWebsite\poll\functions.php on line 8 The fuctions.php file resides in "htdocs\MyWebsite\poll\fuctions.php" The database connect files reside in "htdocs\MyWebsite\func\config.php" and "htdocs\MyWebsite\func\init.php" (They are both needed to make the connection to the db and they work on other files that i have included them) The includes in functions.php that do no work have this path: include('../func/config.php'); include('../func/init.php'); Quote Link to comment https://forums.phpfreaks.com/topic/246647-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1266754 Share on other sites More sharing options...
voip03 Posted September 8, 2011 Share Posted September 8, 2011 Try this code include('func/config.php'); Quote Link to comment https://forums.phpfreaks.com/topic/246647-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1266780 Share on other sites More sharing options...
Muddy_Funster Posted September 8, 2011 Share Posted September 8, 2011 include is a statement, not a function, you shouldn't use () with it. "include ('../func/config.php'); " should really be "include '../func/config.php'; " Quote Link to comment https://forums.phpfreaks.com/topic/246647-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1266801 Share on other sites More sharing options...
GM Revan Posted September 8, 2011 Author Share Posted September 8, 2011 Try this code include('func/config.php'); Thanks alot Voip03 it worked!!! Seems it didn't need to go up one folder for some reason like in some other files that I used the same ../ path. You saved me from multiple file mysql changes in the future. Quote Link to comment https://forums.phpfreaks.com/topic/246647-warning-mysql_fetch_array-expects-parameter-1-to-be-resource-boolean-given-i/#findComment-1266856 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.