Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 6 of 6

Thread: Is it MySQL or me?

  1. #1

    Is it MySQL or me?

    Hi all,

    I've been scratching my head for hours over this. It just doesn't make any sense!

    This doesn't work, it finds 0 rows...

    $query = "SELECT * FROM tblprojectors WHERE brand = 'IBM'";

    but this does...

    $query = "SELECT brand FROM tblprojectors";

    None of the other brand names work either, but all the other columns work fine.

    However this works... (if you use the second query)
    and you'll find IBM listed with all the other brand names..?

    echo $row["brand"];

    What am i missing?

    I'll post more code if needed.

    Thanks

  2. #2
    try:

    Code:
    SELECT * FROM tblprojectors
    and see if there's any records with the brand IBM (manually) to see if your table actually contains rows with IBM...

    You can never underestimate the stupidity of the general public.

  3. #3
    Quote Originally Posted by RvGaTe View Post
    try:

    Code:
    SELECT * FROM tblprojectors
    and see if there's any records with the brand IBM (manually) to see if your table actually contains rows with IBM...
    I can check it in phpMyAdmin. The record exists. I have the same problem with canon, toshiba, sony, etc too. One strange thing though, the brand name values bottom align in the tables in phpMyAdmin, all the others top align....I don't know if that means anything.

  4. #4
    if you go to phpmyadmin and click the sql tab and input that query does it return the results?
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  5. #5
    Are there any whitespace characters around IBM? From your description of them being bottom-aligned I'm thinking they might be stored as "\nIBM", ie. newlineIBM instead of just IBM. Try running:

    Code:
    SELECT brand, (brand = 'IBM'), ORD(brand), ORD(REVERSE(brand)) FROM tblprojectors WHERE brand LIKE '%IBM%';
    That will show you all rows that contain a brand that has "IBM" in it somewhere, will tell you whether or not brand exactly matches IBM and will show you the character codes of the first and last characters. The first character should have code 73, the last should have code 77. For reference, newline characters have code 10.
    Wait, what?

  6. #6
    Quote Originally Posted by Voetsjoeba View Post
    Are there any whitespace characters around IBM? From your description of them being bottom-aligned I'm thinking they might be stored as "\nIBM", ie. newlineIBM instead of just IBM. Try running:

    Code:
    SELECT brand, (brand = 'IBM'), ORD(brand), ORD(REVERSE(brand)) FROM tblprojectors WHERE brand LIKE '%IBM%';
    That will show you all rows that contain a brand that has "IBM" in it somewhere, will tell you whether or not brand exactly matches IBM and will show you the character codes of the first and last characters. The first character should have code 73, the last should have code 77. For reference, newline characters have code 10.
    Thanks that's excellent!
    You're right, there's a newline character at the start of each brand value.

    ...entered this SQL via phpMyAdmin...

    Code:
     
    update tblproducts SET brand = TRIM('\n' FROM brand)
    ...and all is good!

    Thanks for your help

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012