Hennikenno Posted June 18, 2009 Report Share Posted June 18, 2009 Drošivien problēma ir izrunāta neskaitāmas reizes, bet tomēr vēlos uzzināt, kas manā kodā ir nepareizs: <?php require "core/core.php"; dbconn(); head("Charts"); echo"<h2>Charts</h2>"; $res = mysql_query("SELECT * FROM poll WHERE type = q ORDER BY id DESC"); if (mysql_num_rows($res) > 0) { while($array = mysql_fetch_array($res)) { $id = $array['id']; echo"<div class=\"block\">"; $ip = sqlesc(getip()); $uvres = mysql_query("SELECT * FROM poll WHERE type = a AND ip = $ip"); if (mysql_num_rows($uvres) < 3) { echo"<h3>".$array['question']."</h3><form>"; $pores = mysql_query("SELECT * FROM poll WHERE id = $id AND type = o"); while($poarr = mysql_fetch_array($pores)) { echo"<input name=\"poll_$id_option\" type=\"radio\"> ".$poarr['option']."<br/>"; } echo"<input type=\"submit\" name=\"Submit vote\"></form>"; } else { echo"<h3>".$array['question']."</h3>"; $vores = mysql_query("SELECT * FROM poll WHERE type = o AND id = $id"); while($voarr = mysql_fetch_array($vores)) { $option = $voarr['option']; $uares = mysql_query("SELECT * FROM poll WHERE type = a AND option = $option"); $votes = 0; while($uaarr = mysql_fetch_array($uares)) { $votes = $votes + 1; } echo"$option - $votes votes on this!<br/>"; } echo"You have already voted on this enaugh times!"; } } } else { echo"<h3>No polls</h3>"; } foot(); ?> CREATE TABLE IF NOT EXISTS `poll` ( `id` int(10) default NULL, `type` enum('q','o','a') default NULL, `question` varchar(200) default NULL, `option` varchar(200) default NULL, `ip` varchar(100) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; Izpildot so kodu, viss ko saņemu ir: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\web\apache\htdocs\web2\top.php on line 11 No polls Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted June 18, 2009 Report Share Posted June 18, 2009 Man šķiet, ka tam q ir jābūt pēdiņās: SELECT * FROM poll WHERE type = 'q' ORDER BY id DESC Quote Link to comment Share on other sites More sharing options...
marcis Posted June 18, 2009 Report Share Posted June 18, 2009 Jebkurā gadījumā: mysql_query("SELECT...")or die(mysql_error()) Quote Link to comment Share on other sites More sharing options...
Hennikenno Posted June 18, 2009 Author Report Share Posted June 18, 2009 hmm... laikam taisnība. Biki nevērīgs laikam esmu :D .Paldies, viss sanāca ;) 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.