All,

Thanks for your help. I didn't realize all that about ISBN numbers. Thanks
for the tip on shrinking the DB storage requirements as well.

This is for an online advertisment portal for college students to buy and
sell text books, so the ISBN is a means to search on a specific book.

Anyway, thanks to everyone's help, I have it working now.

James

-----Original Message-----
From: Paul Chvostek [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 10, 2003 6:08 PM
To: James Johnson
Cc: [EMAIL PROTECTED]
Subject: Re: MySQL field data type for ISBN numbers


On Sun, Aug 10, 2003 at 05:25:05PM -0700, James Johnson wrote:
>
> I have a MySQL database for books. The ISBN field is set as 
> varchar(15) and I've put a test ISBN number in of 1-1111-111-11.

Note that ISBN numbers are a maximum of 13 characters, not 15.  Ten digits,
three dashes.  If you really want to save space, the last digit is just a
check digit and can always be determined through a formula on the other
digits, so as long as you verify every ISBN before you INSERT it, you can
save another digit.

Heck, if you wanted to, you could store the ISBN as components.  A TINYINT
for the country/region, a MEDIUMINT for each of publisher and publication,
and a SET for the last digit.  Instead of 13 bytes per ISBN, you could
shrink it to slightly more than 4 bytes.

Of course, unless you're dealing with millions of books, or functions that
require queries-by-publisher, it probably isn't worth the effort.

>Can someone tell me why
> this SQL query isn't working?

The advice already given is exactly what I'd submit, so I won't bother
repeating it.  The only thing I'll add is ...  in addition to having your
PHP script print the $query to the browser, you might want to have it print
mysql_error() to see if the db reported anything nasty.  I usually go with
constructs like:

    $q = "SELECT ... WHERE ...";
    if (!$r = mysql_query($q)) {
        $err="db failure: " . mysql_error();
    }
    if (!$err) {
        if (!$row = mysql_fetch_array($r)) {
            $err="query failure: " .  mysql_error();
        }
    }
    if (!$err) {
        // do something useful with $row[]
    } else {
        print "ERROR: <tt>" . $err . "</tt>\n";
    }

It's especially useful if you have a bunch of things that all depend on the
successful completion of previous commands, be they related to MySQL or
anything else.

-- 
  Paul Chvostek                                             <[EMAIL PROTECTED]>
  it.canada                                            http://www.it.ca/
  Free PHP web hosting!                            http://www.it.ca/web/


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to