Results 1 to 6 of 6

Thread: Just when I thought a MySQL read would be easy

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Red face 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

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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);


  3. #3
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    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'.
    Delete it. They just clutter threads anyway.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Re: Just when I thought a MySQL read would be easy

    Quote Originally Posted by penagate View Post
    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

  6. #6
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: Just when I thought a MySQL read would be easy

    Here again, mind the casing.
    Delete it. They just clutter threads anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width