Jump to content

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given i


Recommended Posts

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;
}

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?  :confused: 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');

 

 

 

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. :D

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.