Jump to content
Larry Ullman's Book Forums

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?

 

 

Link to comment
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.

Link to comment
Share on other sites

 Share

×
×
  • Create New...