0

I've been turning in circles for a while now trying to understand what I have done wrong with lines 68 and 110. It comes up with:

"expects parameter 1 to be resource, boolean given"

but I don't understand where my mistake is. Would someone be able to point me in the right direction or explain my error so I can better understand?

I'm really new to PHP (only started learning it last week) so I've been mostly doing my best with tutorials and what I can find online.

Line 68 onwards:

while($row = mysql_fetch_array($query)){
    $card_number = $row['card_number'];
    $card_id = $row['card_id'];
    $card_name = $row['card_name'];
    $card_mana_img = $row['card_mana_img'];
    $card_type = $row['card_type'];
    $card_rarity = $row['card_rarity'];
    $card_set = $row['card_set'];
    }
?>

Lines 99 onwards:

<table>

<tr>
    <td>Number</td>
    <td>Name</td>
    <td>Type</td>
    <td>Mana</td>
    <td>Rarity</td>
    <td>Set</td>

</tr>
<?php while ($row = mysql_fetch_array($query)) { ?>
<tr>
<td><?php echo $card_number; ?></td>
<td><a href="http://mtgdecktechs.com/<?php echo $card_id; ?>"><?php echo $card_name; ?></a></td>
<td><?php echo $card_type; ?></td>
<td><?php echo $card_mana_img; ?></td>
<td><?php echo $card_rarity; ?></td>
<td><?php echo $card_set; ?></td>
</tr>
<?php } ?>
</table>
<br>
<?php echo $paginationCtrls; ?><br>
<?php echo $textline2;?><br>
<?php echo $textline1;?>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Your question is too big. I would modify it and show only code that is relevant – Andrew Mar 30 '16 at 21:19
  • 1
    Possible duplicate of [mysql\_fetch\_array()/mysql\_fetch\_assoc()/mysql\_fetch\_row() expects parameter 1 to be resource or mysqli\_result, boolean given](http://stackoverflow.com/questions/2973202/mysql-fetch-array-mysql-fetch-assoc-mysql-fetch-row-expects-parameter-1-to) – Sean Mar 30 '16 at 21:22
  • @Sean is correct. Your queries fail for whatever reason we will can not tell based on the information you gave us. – bassxzero Mar 30 '16 at 21:24
  • Why are you running a regex against pagenum? Just do `intval()` and be done with it. Have you echoed the value of `$pagenum` to verify that you're getting a sane input? – omnichad Mar 30 '16 at 21:25

1 Answers1

0

Don't use this: $sql = "SELECT number FROM magicorigins_cardset";

Use this: $sql = "SELECT count(*) FROM magicorigins_cardset";

Mojtaba
  • 4,852
  • 5
  • 21
  • 38