mysql-num-rows

PHP and MySQL: Number of rows returned

拜拜、爱过 提交于 2019-12-01 08:16:00
问题 How can I see how many rows the following query returns? mysql_select_db($database_aoldatabase, $aoldatabase); $query1 = "select * from sale where secid = $invoiceno "; $query2 = "select * from sale where secid = $invoiceno "; $maxa = mysql_query ($query1) or die ("Query '$query' failed with error message: \"" . mysql_error () . '"'); $maxa2 = mysql_query ($query2) or die ("Query '$query' failed with error message: \"" . mysql_error () . '"'); $row = mysql_fetch_array($maxa); $row2 = mysql

How can I see if the user's choice in the quiz is correct?

给你一囗甜甜゛ 提交于 2019-11-29 13:02:51
I am trying to check if the answer that the user chose was correct, but it doesn't work properly: <form method="post"> <?php $question = mysql_query("SELECT * FROM `questions`"); $stat = mysql_fetch_assoc($question); $num = mysql_num_rows($question); $questionid = 0; for($i=0;$i<=$num;$i++) { $question = mysql_query("SELECT * FROM `questions` WHERE `id`='$i'"); $stat = mysql_fetch_assoc($question); //if($stat['answer'] == null echo $stat['question'] . '<br />'; echo '<input type="radio" name="a'.$x.'" value="'.$x.'" />' .$stat['answer1']."<br />"; echo '<input type="radio" name="a'.$x.'" value

How can I see if the user's choice in the quiz is correct?

天大地大妈咪最大 提交于 2019-11-28 07:05:43
问题 I am trying to check if the answer that the user chose was correct, but it doesn't work properly: <form method="post"> <?php $question = mysql_query("SELECT * FROM `questions`"); $stat = mysql_fetch_assoc($question); $num = mysql_num_rows($question); $questionid = 0; for($i=0;$i<=$num;$i++) { $question = mysql_query("SELECT * FROM `questions` WHERE `id`='$i'"); $stat = mysql_fetch_assoc($question); //if($stat['answer'] == null echo $stat['question'] . '<br />'; echo '<input type="radio" name=

PDO equivalent of mysql_num_rows or mssql_num_rows

允我心安 提交于 2019-11-28 02:13:40
I know this question has been asked before but it seems like the solutions have been specific to the problem presented. I have a codebase with hundreds of instances where mssql_num_rows is used. Code example: $db->execute($sql); if ($db->getRowsAffected() > 0) { $total = $db->fetch(); In db class: $this->rowsaffected = mssql_num_rows($this->query_result); I can't create generic SELECT count(*) FROM table queries as I have too many specific select statements. I could run a preg_replace to remove everything between SELECT and FROM and then replace with a COUNT(*) and run a second query but this

mysql_num_rows always returns 1

故事扮演 提交于 2019-11-26 11:39:36
问题 The result is always 1: $sql = \'SELECT COUNT(Vote) FROM \' . $table; $res = mysql_query($sql, $conn); $vote_total = mysql_num_rows($res); I ran the $sql query in phpMyAdmin and it returns 3, so the query is not the problem. $vote_total is initialized globally to 0, so that 1 is coming from somewhere. What other information do I need to provide to make helping me easier? Thanks, Ryan 回答1: mysql_num_rows returns the number of selected rows and not the fields of a certain row. Use mysql_fetch

mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

孤人 提交于 2019-11-26 04:56:07
问题 This question already has answers here : Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result (6 answers) Closed 6 years ago . if(mysql_num_rows($result)) { echo \"no match found!\"; } it is throwing an error- Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\\Hosting\\6448289\\html\\includes\\getQuestion.php on line 72 回答1: You need to check the return value of mysql_query $query = 'YOUR QUERY'; $result = mysql_query($query); if (!