SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I'm working through the (very good!) PHP/MySQL tutorial on http://www.webmasterbase.com but I'm having some basic trouble extracting the 'ID' field from my rows. The following code:

    while($row = mysql_fetch_array($result))
    {
    $jokeid = $row["ID"];
    $joketext = $row["JokeText"];
    echo("<P> $jokeid:$joketext </P>");
    }

    Will extract the 'JokeText' but the 'ID' is always blank (yes there is an ID field in the table!)

    Can anyone guess at what I'm doing wrong?

    Thanks,
    Neil.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure there it isn't "id" or something. Are you sure there is data in the id field if you wun the query from the command line does it show numbers in the id field?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the table:

    # --------------------------------------------------------
    #
    # Table structure for table 'jokes'
    #

    CREATE TABLE jokes (
    ID int(11) NOT NULL auto_increment,
    JokeText text NOT NULL,
    JokeDate date DEFAULT '0000-00-00' NOT NULL,
    PRIMARY KEY (ID)
    );

    #
    # Dumping data for table 'jokes'
    #

    INSERT INTO jokes VALUES( '1', 'Chicken......', '2000-11-12');

    ID should have the value '1' but it's always blank when I read it back... For that matter, I believe JokeDate is also blank when I read it but JokeText I can get to just fine!

    Any ideas???

    Thanks,

    Neil.

  4. #4
    SitePoint Member
    Join Date
    Nov 2000
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I've sorted this one out!

    I'd foolishly done "SELECT JokeText FROM jokes" as my SQL query so obviously only the JokeText field was available to me! Doh!

    Thanks for the help,

    Neil.

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It always helps to provide as much of your code as possible to allow others to help troubleshoot, if you do not show use the sql statement, we will have to assume that is was done correctly.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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