a-mo Posted September 13, 2008 Share Posted September 13, 2008 Hi, I'm new here so I'm not sure sure to post in the right place or in the right way. I have a problem. I'm trying to propose an on-line estimate on my site, using php. The problem is the "echo" at the end of the script doesn't seem to echo anything. Here's the code: <?php function indication() { $Input=array(); $Input[0]=$_GET["ecma"]; $Input[1]=$_GET["php"]; $IndexSum=array_sum($Input); $Index=$IndexSum+1; $PageNb=$_GET["page_nb"]; $PageTran=$PageNb*90; $Pages=$PageTran+180; $Total=$Pages*$Index; echo $Total; } ?> Any ideas? I'm new to php, it may be something obvious. Many thanks. Quote Link to comment Share on other sites More sharing options...
Mchl Posted September 13, 2008 Share Posted September 13, 2008 Did you call this function? Quote Link to comment Share on other sites More sharing options...
a-mo Posted September 13, 2008 Author Share Posted September 13, 2008 Sorry, I'm not sure what you mean. I have a form in an html file, with "action="(the php file)", the php previous code is in the .php. I receive no errors from the server when proceeding on the site. Quote Link to comment Share on other sites More sharing options...
a-mo Posted September 13, 2008 Author Share Posted September 13, 2008 Ok, indeed, the function wasn't called. Stupid me. It was just missing "indication();" after the function. Thank you. nb: please be lenient, I'm learning php since yesterday. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted September 13, 2008 Share Posted September 13, 2008 3 pointers: 1. Why is it a function? I see no point in having this a function. 2. Why go through all that trouble of making like, 3 arrays and doing simple arithmetic when you can just do: <?php $index = ($_GET['ecma'] + $_GET['php']) + 1; $pages = ($_GET['page_nb'] * 90) + 180; echo $index * $pages; ?> 3. I'd really suggest starting variables with a lowercase letter and then use camelCase. It makes it easier to not lose track of a variable's case. 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.