mysql_fetch_array() problem

This gives a plank page:

$bk=isset($_GET["book".$no]) ? $_GET["book".$no] : "";
$ch=isset($_GET["chapter".$no]) ? $_GET["chapter".$no] : "";
$vs=isset($_GET["verse".$no]) ? $_GET["verse".$no] : "";
$source=isset($_GET["source".$no]) ? $_GET["source".$no] : "";
$sourceAbb=Array("kjv", "mt", "mtnv", "tr");
$SourceName=Array("King James", "Masoretic Text", "Masoretic No Vowels", "Textus Receptus");
$SourceTable=Array($dbTable3, $dbTable7, $dbTable9, $dbTable8);
for($i=0; $i<count($SourceTable); $i++){
		$sql = "SELECT * FROM ".$SourceTable[$i]." WHERE book = '".$bk."' AND chapter= '".$ch."'";
		if($vs != 'all'){
			$sql .= " AND verse= '".$vs."'";
		$sql .= " ORDER BY id ASC";
		//echo $sql;
	$result = mysql_query($query);
	while($row = mysql_fetch_array($result)){
		$id[] = $row['id'];
		$bookTitle[] = $row['book_title'];
		$book[] = $row['book'];
		$bookAbb[] = $row['book_abb'];
		$chapter[] = $row['chapter'];
		$verse[] = $row['verse'];
		$textData[] = $row['text_data'];
<div style="float: left; margin: 5px 0px 0px 0px; background-color: #7A1010; width: 183px; height: 19px; border: 1px solid #7A1010; color: white; font-weight: bold; text-align: left; padding: 0px 0px 0px 5px;">
	<span style="float: left; padding: 2px 10px 0px 2px; color: #FFFFFF; font-family: arial; font-weight:bold; font-size: 13px"><input id="chk_all" name="checkallresults" type="checkbox" style="float: left;" onClick="if(this.checked == true){for (i=0; i<document.getElementsByName('checkresult_<?php echo $no; ?>').length; i++){document.getElementsByName('checkresult_<?php echo $no; ?>')[i].checked = true ;
}}else{for (i=0;i<document.getElementsByName('checkresult_<?php echo $no; ?>').length; i++){document.getElementsByName('checkresult_<?php echo $no; ?>')[i].checked = false;}}" />all</span>
	<span style="float: left; height: 10px; padding: 2px 10px 0px 2px; color: #FFFFFF; font-family: arial; font-weight: bold; font-size: 13px"><?php echo $bookTitle[0]. " " .$chapter[0];?></span>
<div id="txt_<?php echo $book[0]."_".$chapter[0]."_".$no; ?>" style="float: left; background-color: #EAE8C8; margin: 0px 0px 0px 0px; width: 178px; height: 407px; border: 1px solid #7A1010; padding: 5px 5px 0px 5px; overflow-y: auto; overflow-x: hidden;">
	for($tdid=0; $tdid < count($id); $tdid++){
		echo "\	\	\	\	\	<p id=\\"regular[]\\" name=\\"bibletext\\" style=\\"float: left; text-align: left; width: 155px; display: block; padding: 0px 2px 0px 2px; font-size: 12px;\\"><input id=\\"check".$no."_".$tdid."\\" name=\\"checkresult_".$no."\\" type=\\"checkbox\\" onclick=\\"\\" value=\\"".$id[$tdid]."\\" /><span style=\\"font-weight: bold; margin: 2px;\\">"."[".$id[$tdid]."] - ".$verse[$tdid]."</span>";
		$strText = stripslashes(mysql_real_escape_string($textData[$tdid]));
		echo "</p>\
	echo "\	\	\	\	\	</div>\

But when I remove the if($result) then it would point out:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in thewheelofgod\ wotexts\getfiles\getTextinclude.php on line 22

What’s the solution?

Note you’re running if ($result) before a result variable even exists.

Also, a boolean given means it’s returning false when it expects a resource, long story short, your query in one way or another is wrong.

I see you have $sql echo’d but commented out, mind showing what it outputs, as that is how you can get to the bottom of it.

So in other words:

$result = mysql_query($query);

SELECT * FROM textus_receptus WHERE book = ‘40’ AND chapter= ‘1’ ORDER BY id ASC

Oh I forgot to change $query to $sql.