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