websteve Posted July 14, 2010 Share Posted July 14, 2010 I am trying to update a table, but I am getting intermittent errors. If I run the program and change the credit card number, for example, sometimes it works and other times it doesn't. Also, if I change the expiration to say, 11/12, it returns some type of decimal sequence. The expiration column is set for Varchar. I verified that the variables are being sent through. If anyone can tell me what I am doing wrong, I would appreciate it. Here's the code: $credit_update = "UPDATE Credit SET Credit_Card_Number='$credit_card_number', Expiration=$expiration WHERE ID = '" . mysql_real_escape_string($cust_id) . "'"; mysql_query($credit_update) or die('Could not connect to credit table: ' . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/207750-update-not-working-sometimes/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 This: 11/12 is a math expression, 11 divided by 12 This: '11/12' is a string that represents something specific to your application. Strings are enclosed in single-quotes in a query. Quote Link to comment https://forums.phpfreaks.com/topic/207750-update-not-working-sometimes/#findComment-1086029 Share on other sites More sharing options...
websteve Posted July 14, 2010 Author Share Posted July 14, 2010 OK, that makes sense. Thanks. What about this part: $credit_update = "UPDATE Credit SET Credit_Card_Number='$credit_card_number', The credit card number sometimes is updated and sometimes it doesn't take. Any ideas? - Steve Quote Link to comment https://forums.phpfreaks.com/topic/207750-update-not-working-sometimes/#findComment-1086036 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2010 Share Posted July 14, 2010 So, what is the column definition of Credit_Card_Number? And what exactly is the symptom or error that leads you to believe that "it doesn't take." We only see the information you supply in your posts and "it doesn't take." could mean 3-6 different things, each with a different cause. You must be exact when describing problems. Quote Link to comment https://forums.phpfreaks.com/topic/207750-update-not-working-sometimes/#findComment-1086041 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.