Jump to content

albaserver

Members
  • Posts

    13
  • Joined

  • Last visited

albaserver's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I'm trying to write a better PHP code to create and manage my website. I would like to start a MVC approach with PHP, using OOP. So I can manage the updates in a better way. For example, to begin my project, I would try with the shipping cost of our products, using a Class without merge the PHP and HTML code. Something like this: $shippingcost=new ShippingCost(); $shippingcost->state="Italy"; $shippingcost->get(); // here I have an array with cost, discount, time ecc. And If I need it in JSON, I write: $shippingcost->get("JSON"); // here I have the JSON with cost, discount, time ecc. I wrote the Class in this way: class ShippingCost { public $state; private $arrayReturned; public function __construct() { $this->stato="Italy"; // the default state } public function __destruct() { } public function get($format="array") { $this->arrayReturned=array( "cost" => 3.99, "costDiscounted" => 7.99, "discount" => "50%" ); if (strtolower($formato)=="json") { $this->arrayReturned=json_encode($this->arrayReturned); } return $this->arrayReturned; } } It works well, but I need to get the values from a MySQL db. How can pass the MySQL connection to the Class? I'm not able to do this. Thanks in advance and have a great 2015. Rob.
  2. I solved. It's a bug of the installed version of PHP on SLES Now it works great.
  3. "Additional .ini files parsed" in phpinfo() there is "/etc/php5/conf.d/suhosin.ini" as well. Yes! When we found out that the problem was HTTP POST, I prepared an empty page with the only HTTP POST code and a very simple form. Nothin'else. in phpinfo() is 1000 without comma or point. Rob
  4. to mikosiko: max_input_vars is 1000 to ginerjim: no more code, only that one I posted in a blank page, nothin'else
  5. Sorry but I think I will give up. Never seen this bug and I don't know how to fix it. Today I wrote to the sysadmins to have a new VM in our Intranet 'cause no one I asked for was able to help me
  6. In every case, the script returns only the first checkbox selected If I check the second and the third one (value 1 and 2), I get: Array( [somethingelse] => Array ( [0] => 1 ))
  7. The code is only the one I posted Now I try with this version: <?php session_start(); error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); if (isset($_POST["somethingelse"])) { echo '<pre>' , print_r($_POST,true) , '</pre>'; } else { ?> <form method="post"> <input type="hidden" name="nickname" value="Rob"> <input type="checkbox" name="somethingelse[0]" value="0"> 0<br> <input type="checkbox" name="somethingelse[1]" value="1"> 1<br> <input type="checkbox" name="somethingelse[2]" value="2"> 2 <br><br> <input type="submit"></form> <?php } ?> But the error is still the same. Only the first item of the array come via POST!! What else can I try?! Rob
  8. The code is very very very simple: <?php session_start(); error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); if (isset($_POST["user_rights"])) { echo '<pre>' , print_r($_POST,true) , '</pre>'; } else { ?> <form method="post"> <input type="hidden" name="nickname" value="Rob"> <input type="checkbox" name="user_rights[]" value="0">0<br> <input type="checkbox" name="user_rights[]" value="1">1<br> <input type="checkbox" name="user_rights[]" value="2">2<br> <br> <input type="submit"></form> <?php } ?> If I check ALL the checkboxes, the result is: Array ( [nickname] => Rob [user_rights] => Array ( [0] => 0 ) ) It could be some wrong configuration of the server? But where?!?!
  9. If I check all the checkboxes (three) I see only the first one, here it is: Array( [user_rights] => Array ( [0] => 0 ))
  10. I have a root access on that server, but I'm not able to get them. Can u tell me how to do that so I give you the infos?
  11. PHP: 5.3.8 Apache/2.2.12 (Linux/SUSE) Ask me if any other info can be useful
  12. First of all thanks for your reply. I tried your code but the behaviour it's always the same. On the first server it doesn't work, but if I try on another server it works well. None knows a bug for this case?
  13. Hello to everyone, I have a strange problem and I'm not able to solve it by myself and I need your help! I have three simple checkboxes that process via POST their value. But with PHP I cannot have an array with the three indexes (if everyone checked) but only an array with the first checkbox checked. The code is very simple: <?php $scelta = isset($_POST['user_rights']) ? $_POST['user_rights'] : array(); if (isset($_POST["user_rights"])){ print_r($scelta);}else{ ?> <form method="post"><input type="checkbox" name="user_rights[]" value="0"> 0<br><input type="checkbox" name="user_rights[]" value="1"> 1<br><input type="checkbox" name="user_rights[]" value="2"> 2 <input type="submit"></form> <?php} ?> The output if I check all the checkboxes is: Array ( [0] => 0 ) If I try this code on another server it works (it returns the complete array), but if i run it on my web server, it doesn't (it returns only the first item). Do you have any experience with this error? Do you know if there is some configuration to change? Thanks in advance. Rob
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.