Just when I thought a MySQL read would be easy
Code:
$q = "SELECT * FROM rev_counter";
$result = mysql_query($q) or die(mysql_error());
$num = mysql_num_rows($result);
while($record = mysql_fetch_assoc($result))
{
$id = $record["cid"];
If I echo $num I get a 170 odd count, which looks right.
However if I echo $id the value is null, yet no error messages. Seems to work fine on a Win box but doesn't want to play nice on a nix server :(
It's probably obvious to a guru.... what am I doing wrong, and why does the nix server hate me :(
Re: Just when I thought a MySQL read would be easy
nothing is obviously wrong -- but try using print_r() to see what is being returned inside of your loop:
PHP Code:
while($record = mysql_fetch_assoc($result)){
print_r($record);
}
Re: Just when I thought a MySQL read would be easy
Make sure you don't mix up cases; unix is mostly case sensitive.
As you do seem to return the correct amount of results I suspect that cid is the little bugger.
Check the database, it might be something like 'cID' or 'CID'.
Re: Just when I thought a MySQL read would be easy
In this case the case sensitivity is dependant on the collation type of the database table and not the host operating system. Try enabling strict error messages.
PHP Code:
error_reporting(E_ALL | E_STRICT)
Re: Just when I thought a MySQL read would be easy
Quote:
Originally Posted by
penagate
In this case the case sensitivity is dependant on the collation type of the database table and not the host operating system. Try enabling strict error messages.
PHP Code:
error_reporting(E_ALL | E_STRICT)
Thanks dude, weirdly there's something strange going on. I put in a little script to extract field names etc and when I browse to it I'm getting page not found errors :eek:
Re: Just when I thought a MySQL read would be easy
Here again, mind the casing.