Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
daddytiger

Ex2 (Coffee Site) - Customer Phone Number: String Not Integer?

Recommended Posts

Late in chap 10, in testing checkout.php, found that my own phone number was not being entered correctly into the phone field of table customers (database ecommerce2).

 

1) Pg 190 and in sql file, creating TABLE `customers`: ... `phone` CHAR(10).

 

2) Pg 289 and in sql file, CREATE PROCEDURE add_customer ... variable p (INT) - should be CHAR(10)?

 

3) Pg 301 step 16 and in checkout.php (line 134?) after if (empty($shipping_errors)) {:

 

in the query CALL add_customer('$e', '$fn', '$ln', '$a1', '$a2', '$c', '$s', $z, $p, @cid),

 

$p needs quotes like other string fields:  i.e., CALL add_customer('$e', '$fn', '$ln', '$a1', '$a2', '$c', '$s', $z, '$p', @cid)

 

Using phpmyadmin. Steps 2 & 3 seemed to fix it.So step 1 is correct, no?

 

Interesting that the zip can be an integer but phone (apparently) needs to be a string. Because we did a str_replace on the phone?

 

 

Share this post


Link to post
Share on other sites

I'll double check this, but as for the zips and phones, the zip in the US will always be an integer (unless you want to support +4). For the phone, I had to make it a string due to the limits of the integer type in MySQL. Plus this supports someone adding an extension. But you could make it a BIGINT, if you'd rather.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...