Gossamer Forum
Home : General : Internet Technologies :

PHP problem

Quote Reply
PHP problem
I'm trying to get it so that when a verse exists after the one being shown, it gives a link to view it and when the verse does not exist, it displays "end" or "start". I thought that I could do this by making a mysql query and seeing if it returned with a value. Somehow, it's not working. In the database, the field doesn't exist yet it's still returning as a value.



Code:


$previous_sql = @mysql_query("SELECT bible_text FROM ptv3_bible_ot WHERE bible_book = '$book' AND bible_chap = '$jump_chap' AND bible_verse = '$verse_minus'");

if(!$previous_sql) {
echo("<span class='smtextblk'>start</span>");
} else {
echo("<a href='" . $PHP_SELF . "?bible_action=" . $bible_action . "&view=" . $view . "&book=" . $book . "&jump_chap=" . $jump_chap . "&jump_verse=" . $verse_minus . "' class='bible_link'>previous</a>");
}


Can anyone see anything wrong with this?
Quote Reply
Re: [JoFrRi] PHP problem In reply to
Try printing your query, rather than executing it directly. i.e;

Code:
$query = "SELECT bible_text FROM ptv3_bible_ot WHERE bible_book = '$book' AND bible_chap = '$jump_chap' AND bible_verse = '$verse_minus'";
$previous_sql = @mysql_query($query);

echo $query;

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [JoFrRi] PHP problem In reply to
The problem is, the query executes fine, thus your if statement: if(!$previous_sql) tests true. You should test: if(mysql_num_rows($previous_sql) == 0) instead.


Just Another Random Thought
Quote Reply
Re: [greykher] PHP problem In reply to
Wonderful wonderful, my logic didn't pick up on that until you mentioned it but I completely see what was wrong now. Thanks.