MySQL Forums
Forum List  »  PHP

Re: PHP/MySQL Reading Database Field Help!
Posted by: Peter Brawley
Date: July 23, 2019 03:53PM

If "learn as I go" is to rise above hacking (which doesn't deliver reliable results), a systematic approach is needed: first write the logical steps required by the job, then translate that into pseudocode, then translate that into the language you're writing.

The pseudocode for your job would be something like ..

connect or exit on error
assemble query
submit query or exit on error
check no. of rows returned, if 0 exit
fetch target row(s)
examine row values
...

As you can see, we don't try to fetch a row till we know there's one available.

PHP says $row is an array. Because it's the result of fetch_assoc(). But you called that func before checking that the row exists.

Re mysqli_num_rows(), check its manual page for syntax.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.