Why are these "undefined variables" after the sql?

My page shows these:
`SELECT * FROM bible WHERE (book = ‘11’ AND chapter= ‘8’) AND (text_data
LIKE ‘%altar%’ OR text_data LIKE ‘%offer%’ OR text_data LIKE ‘%burn%’)
ORDER BY id ASC

SELECT * FROM bible WHERE (book = ‘2’ AND chapter= ‘8’) AND (text_data
LIKE ‘%altar%’ OR text_data LIKE ‘%offer%’ OR text_data LIKE ‘%burn%’)
ORDER BY id ASC

Notice: Undefined variable: bookTitle9b in function-give.php on line 79

Notice: Undefined variable: chapter9b in function-give.php on line 79

Notice: Undefined variable: recordType9b in function-give.php on line 80

Notice: Undefined variable: chapter9b in function-give.php on line 80

CREATE TABLE IF NOT EXISTS 1kings8_and_
(1ki8_and__ID int(5) NOT NULL AUTO_INCREMENT PRIMARY KEY,
date_time DATETIME,
postorder INT(3),
spoke INT(3),
comments varchar(1000),
joinids varchar(50),
words varchar(120),
color varchar(30)
)

Notice: Undefined variable: textData9b in function-give.php (7.6 KB)
function-give.php on line 97`

Is it possible that the second query doesn’t return any values? You run the queries to build the arrays, but then use them whether or not they are both created. Your line 78

	if(isset($bookTitle9a[0]) || isset($bookTitle9b[0])){	

checks to see if either of those variables exist, but not that they both do. So if the first query returns results but the second does not, you plough right on with that loop using variables that don’t exist, hence the error message.

1 Like

It seems to me that the values of the 2nd query are not created. But the 2nd sql statement shows ok.

Why isn’t it defining?

droopsnoot gave you the answer to that, your conditional logic is foobar

Try changing the logical OR to logical AND .

oh i see what he meant. Yes i think that makes sense

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.