cheechm Posted October 14, 2008 Share Posted October 14, 2008 Hi, I am trying to insert a number starting with a zero into a MySQL table, however the 0 is always taken off. I tried all of the int types. What is wrong? $sql = "UPDATE customers SET telephone = '07798494825'; Thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted October 14, 2008 Share Posted October 14, 2008 store it as varchar, not as a number. A phone number is just a string that happens to contain numeric characters Quote Link to comment Share on other sites More sharing options...
cheechm Posted October 14, 2008 Author Share Posted October 14, 2008 Thanks but now this: UPDATE customers SET `number` = '07894512345' AND address = 'London' AND email = 'niaaaaak@live.com' AND name = 'Nick' AND postcode = 'WE1 3SW' AND company = 'Design' WHERE cid = 4 It sets number as 1? what!! Number = varchar(40) latin1_swedish_ci Thanks so far! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 14, 2008 Share Posted October 14, 2008 You don't want to use "AND" like that. If you are setting more than one column separate them with commas: UPDATE customers SET `number` = '07894512345', address = 'London', email = 'niaaaaak@live.com', name = 'Nick', postcode = 'WE1 3SW' Ken Quote Link to comment Share on other sites More sharing options...
Barand Posted October 14, 2008 Share Posted October 14, 2008 That's because you are setting to the result of a boolean expression with those ANDs. Correct syntax is UPDATE customers SET `number` = '07894512345', address = 'London', email = 'niaaaaak@live.com', name = 'Nick', postcode = 'WE1 3SW', company = 'Design' WHERE cid = 4 Quote Link to comment Share on other sites More sharing options...
cheechm Posted October 14, 2008 Author Share Posted October 14, 2008 Excellent.. All fixed up! Thanks for quick repplies. Nick Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 14, 2008 Share Posted October 14, 2008 Edit, third explanation - AND is a logical operator. `number` is being set to all the true/false results of the expressions (which are all true), resulting in a true (1) value. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 14, 2008 Share Posted October 14, 2008 That was my (second) explanation - boolean expression Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.