Kracker Posted January 11, 2012 Report Share Posted January 11, 2012 (edited) Sveiki! Palīdzat ar skriptu, nu kaut pakaries, bet rāda kļūdu - Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home_new/project/public_html/modules/poll/inc/functions.php on line 27 Line 27 ir while($row = mysql_fetch_array($result, MYSQL_ASSOC)) 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 if($_SESSION["radamais"]!="'".$pollID."'"){ $_SESSION["radamais"] = $pollID; } $pollStartHtml = ''; $pollAnswersHtml = ''; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ... Edited January 11, 2012 by Kracker Quote Link to comment Share on other sites More sharing options...
ezis Posted January 11, 2012 Report Share Posted January 11, 2012 (edited) Ja pareizi sapratu, tad $result atgriež boolean false! Konekcija ir veikta? http://php.net/manua...l-query.php šjiēet! Kas ir tas? o0 if($_SESSION["radamais"]!="'".$pollID."'") http://php.net/manua....comparison.php Edited January 11, 2012 by ezis Quote Link to comment Share on other sites More sharing options...
daGrevis Posted January 11, 2012 Report Share Posted January 11, 2012 Kļūda kverijā un tas atgriež būleānu, ne resursu... viss! Quote Link to comment Share on other sites More sharing options...
daGrevis Posted January 11, 2012 Report Share Posted January 11, 2012 var_dump($result); exit; Quote Link to comment Share on other sites More sharing options...
briedis Posted January 11, 2012 Report Share Posted January 11, 2012 Skatīti PIESPRAUSTO topiku - http://php.lv/f/topic/15467-warning-mysql-result-supplied-argument-is-not-a-valid-mysql-result/ Quote Link to comment Share on other sites More sharing options...
Kracker Posted January 12, 2012 Author Report Share Posted January 12, 2012 Pilns kods. Uz localhost-a man viss strādāja ideāli, bet kā uzliku uz servera, tā rāda kļūdu. function getPoll($pollID){ $res = mysql_query("SELECT * FROM polls LEFT JOIN pollAnswers ON polls.pollID = pollAnswers.pollID WHERE polls.pollID = " . $pollID . " ORDER By pollAnswerListing ASC"); //echo $query;jquery if($_SESSION["radamais"]!="'".$pollID."'"){ $_SESSION["radamais"] = $pollID; } $pollStartHtml = ''; $pollAnswersHtml = ''; while($row = mysql_fetch_array($res)) { $pollQuestion = $row['pollQuestion']; $pollAnswerID = $row['pollAnswerID']; $pollAnswerValue = $row['pollAnswerValue']; if ($pollStartHtml == '') { $pollStartHtml = '<div id="pollWrap"><form name="pollForm" method="post" action="inc/functions.php?action=vote"><h3>' . $pollQuestion .'</h3><ul>'; $pollEndHtml = '</ul><input type="submit" name="pollSubmit" id="pollSubmit" value="Balsot" /> <span id="pollMessage"></span><img src="ajaxLoader.gif" alt="Ajax Loader" id="pollAjaxLoader" /></form></div>'; } $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; } function getPollID($pollAnswerID){ $result = mysql_query("SELECT pollID FROM pollAnswers WHERE pollAnswerID = ".$pollAnswerID." LIMIT 1"); $row = mysql_fetch_array($result); return $row['pollID']; } function getPollResults($pollID){ $colorArray = array(1 => "#ffcc00", "#00ff00", "#cc0000", "#0066cc", "#ff0099", "#ffcc00", "#00ff00", "#cc0000", "#0066cc", "#ff0099"); $colorCounter = 1; $query = "SELECT pollAnswerID, pollAnswerPoints FROM pollAnswers WHERE pollID = ".$pollID.""; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { if ($pollResults == "") { $pollResults = $row['pollAnswerID'] . "|" . $row['pollAnswerPoints'] . "|" . $colorArray[$colorCounter]; } else { $pollResults = $pollResults . "-" . $row['pollAnswerID'] . "|" . $row['pollAnswerPoints'] . "|" . $colorArray[$colorCounter]; } $colorCounter = $colorCounter + 1; } $query = "SELECT SUM(pollAnswerPoints) FROM pollAnswers WHERE pollID = ".$pollID.""; $result = mysql_query($query); $row = mysql_fetch_array( $result ); $pollResults = $pollResults . "-" . $row['SUM(pollAnswerPoints)']; echo $pollResults; } //VOTE START if ($action == "vote"){ if (isset($_COOKIE["poll" . getPollID($pollAnswerID)])) { echo "voted"; } else { $query = "UPDATE pollAnswers SET pollAnswerPoints = pollAnswerPoints + 1 WHERE pollAnswerID = ".$pollAnswerID.""; mysql_query($query) or die('Error, insert query failed'); setcookie("poll" . getPollID($pollAnswerID), "", time()+7776000, "/~adrese/", ".adrese.lv"); getPollResults($_SESSION["radamais"]); unset($_SESSION["radamais"]); } } Quote Link to comment Share on other sites More sharing options...
Kracker Posted January 12, 2012 Author Report Share Posted January 12, 2012 Kļūda kverijā un tas atgriež būleānu, ne resursu... viss! Bet kā tu vari izskaidrot to, ka uz localhost strādā, bet uz servera, kad uzliek nestrādā? Quote Link to comment Share on other sites More sharing options...
Grey_Wolf Posted January 12, 2012 Report Share Posted January 12, 2012 Bet kā tu vari izskaidrot to, ka uz localhost strādā, bet uz servera, kad uzliek nestrādā? a) nepareiza DB parole, vai uservards, vai arii nepareizs serveris - uz serveriem bieži vien nav loclhost, bet ir konkrēts db serveris . b) tabulas uz tava localhost un servera ir dažādas - vai arī kāda tabula trūks, vai trūkst kāda no kolonnām, Quote Link to comment Share on other sites More sharing options...
Kracker Posted January 12, 2012 Author Report Share Posted January 12, 2012 a) nepareiza DB parole, vai uservards, vai arii nepareizs serveris - uz serveriem bieži vien nav loclhost, bet ir konkrēts db serveris . b) tabulas uz tava localhost un servera ir dažādas - vai arī kāda tabula trūks, vai trūkst kāda no kolonnām, Abi norādītie punkti ir pareizi, takš nevar būt ka viss strādā uz localhost, bet šis pēlšņi nestrādās un tabulas, kolonas arī netrūkst, tikko pārbaudīju. :) Tādēļ saku, kaut pakaries, bet nestrādā. :D Quote Link to comment Share on other sites More sharing options...
daGrevis Posted January 12, 2012 Report Share Posted January 12, 2012 mysql_error() Quote Link to comment Share on other sites More sharing options...
Kracker Posted January 12, 2012 Author Report Share Posted January 12, 2012 Paldies, tuvu bija Grey_Wolf, pāreksportējot tabulas, viens lielais burts(pollAnswer) tabulai pārvērtās par mazo (pollanswers). Liels Paldies! :) Quote Link to comment Share on other sites More sharing options...
aika Posted January 14, 2012 Report Share Posted January 14, 2012 (edited) tādēļ vienmēr vismaz if (!$res) {print mysql_error() ; exit;} Edited January 14, 2012 by aika Quote Link to comment Share on other sites More sharing options...
daGrevis Posted January 16, 2012 Report Share Posted January 16, 2012 Kādreiz, kad strādāju ar mysql_* funckijām... darīju tā: mysql_query($sql) || mysql_error(); Tulkojas apmēram: Izpildam pieprasījumu vai izvadam kļūdas paziņojumu. Quote Link to comment 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.