gdeliana Posted October 21, 2012 Share Posted October 21, 2012 (edited) Ok, i think this is the best place for this question. I have the following problem that no matter what i do the number doesn't add to the sql variable. $i=interest rate, which is a row in sql database, i need to add 1 to it. The result is 1. Which should have been for example 1.01 if $i=1. Here is the code: $result1 = mysql_query("SELECT interest_rate FROM list1") or die(mysql_error()); $row1 = mysql_fetch_array($result1); $i = $row1['interest_rate']; echo $i . "<br/>"; echo $i+1 . "<br/>"; On echo $i i get the row values. On $i+1 i get only 1 in a column repeated vertically. WHY?? PLSSSSS help!!!! Edited October 21, 2012 by gdeliana Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 21, 2012 Share Posted October 21, 2012 Is that your actual code, cut and pasted? Quote Link to comment Share on other sites More sharing options...
gdeliana Posted October 21, 2012 Author Share Posted October 21, 2012 Is that your actual code, cut and pasted? Yeah,well that's it. I actually forgot to change the ord interest in english, i left it in my language, but already edited it. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 21, 2012 Share Posted October 21, 2012 (edited) I just wanted to make sure it was accurate because when I run it, it works for me. I've tried to make it fail several ways, but it worked every time. Edited October 21, 2012 by Pikachu2000 Quote Link to comment Share on other sites More sharing options...
gdeliana Posted October 21, 2012 Author Share Posted October 21, 2012 (edited) So ok i'm using xampp server. What's the damn problem, is keeping me all the day here. Do i need to use any parameter when fetching the array. Maybe the array is not considered as numbers. In sql (phpmyadmin) i have the type of row set as int(6), encoding:UTF8. Edit: sorry no encoding is set for this row. Edited October 21, 2012 by gdeliana Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 21, 2012 Share Posted October 21, 2012 What are the values of $i? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 21, 2012 Share Posted October 21, 2012 How are you getting a decimal value back from an INT field? An INT field will convert any decimal value to an INTeger. The field should be FLOAT, DOUBLE or DECIMAL. Quote Link to comment Share on other sites More sharing options...
gdeliana Posted October 21, 2012 Author Share Posted October 21, 2012 How are you getting a decimal value back from an INT field? An INT field will convert any decimal value to an INTeger. The field should be FLOAT, DOUBLE or DECIMAL. The values are from $i are: 0.01; 0.02; ..........etc. Do i need to type here 35 rows?? I get the same values weather i change it to: decimal, int, float. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 21, 2012 Share Posted October 21, 2012 You're certainly not getting a value of 0.01 from an INT field in the database. What is it you're trying to accomplish with this? Quote Link to comment Share on other sites More sharing options...
gdeliana Posted October 21, 2012 Author Share Posted October 21, 2012 You're certainly not getting a value of 0.01 from an INT field in the database. What is it you're trying to accomplish with this? I want to create a form for helping out customers for choosing banks, where to deposit. I have in a database all the requirements of each bank (like minimal deposit, interest rate and so on) So i need to fetch the database according to user input and at the same time from those results, the code must be able to calculate the future value of the deposit in the selected banks which fulfill the customer requirements. Quote Link to comment Share on other sites More sharing options...
gdeliana Posted October 21, 2012 Author Share Posted October 21, 2012 I want to create a form for helping out customers for choosing banks, where to deposit. I have in a database all the requirements of each bank (like minimal deposit, interest rate and so on) So i need to fetch the database according to user input and at the same time from those results, the code must be able to calculate the future value of the deposit in the selected banks which fulfill the customer requirements. I have found the problem: the interest column was in varchar ....i guess it's always my fault . Thanks buddies!!! Really!!! I am trying to output the results with echo, but the problem is as i concatenate a lot of php variables and strings i cannot insert HTML markup, coz i always must end the first part of the bracket and than concatenate another value. How do i put the entire echo result in a div as i have a lot of concatenations. 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.