tomtom Posted July 29, 2008 Share Posted July 29, 2008 Hey. I've done this function a million times but today it went wrong! lol. any ideas why? code snippet below: <?php $get_produc = mysql_query("SELECT * from `products`"); while($product = mysql_fetch_array($get_produc)) { echo " <tr> <td><input type=\"checkbox\" name=\"products[]\" value=\"" . $product['id'] . "\""; if($product[rec]=="yes") { echo " checked disabled"; } echo ">" . $product['name'] . "</td> </tr>"; } echo " </table> </div> <input type=\"submit\" name=\"installation\" class=\"sub\" value=\"Install\"> </form> </div>"; }else{ $products = implode("/", $_POST[products]); } ?> cheers the error is: Warning: implode() [function.implode]: Invalid arguments passed in /home/deltamax/public_html/delta/updater.php on line 100 line 100 is $products = implode("/", $_POST[products]); Quote Link to comment Share on other sites More sharing options...
craygo Posted July 29, 2008 Share Posted July 29, 2008 What error are you getting. Just a quick look, you may want to enclose your variables in single quotes. $product['rec'] and $_POST['products']. Ray Quote Link to comment Share on other sites More sharing options...
tomtom Posted July 29, 2008 Author Share Posted July 29, 2008 the error is: Warning: implode() [function.implode]: Invalid arguments passed in /home/deltamax/public_html/delta/updater.php on line 100 and yeah I have now but still getting the error. Quote Link to comment Share on other sites More sharing options...
d.shankar Posted July 29, 2008 Share Posted July 29, 2008 Try now <?php $get_produc = mysql_query("SELECT * from `products`"); while($product = mysql_fetch_array($get_produc)) { echo " <tr> <td><input type=\"checkbox\" name=\"products[]\" value=\"" . $product['id'] . "\""; if($product['rec']=="yes") { echo " checked disabled"; } echo ">" . $product['name'] . "</td> </tr>"; } echo " </table> </div> <input type=\"submit\" name=\"installation\" class=\"sub\" value=\"Install\"> </form> </div>"; }else{ $products = implode("/", $_POST['products']); } ?> Quote Link to comment Share on other sites More sharing options...
tomtom Posted July 29, 2008 Author Share Posted July 29, 2008 Nope. Error still there. ??? Quote Link to comment Share on other sites More sharing options...
craygo Posted July 29, 2008 Share Posted July 29, 2008 do you have a products array being set from your POST form?? Quote Link to comment Share on other sites More sharing options...
tomtom Posted July 29, 2008 Author Share Posted July 29, 2008 yeah when you do name="bla[]" it counts as an array. i've done it before. Quote Link to comment Share on other sites More sharing options...
craygo Posted July 29, 2008 Share Posted July 29, 2008 yes but if you echo it out are you getting anything print_r($_POST['products']); Ray Quote Link to comment Share on other sites More sharing options...
tomtom Posted July 29, 2008 Author Share Posted July 29, 2008 Nope. Nothing comes out when I do that. Quote Link to comment Share on other sites More sharing options...
craygo Posted July 29, 2008 Share Posted July 29, 2008 Well that is why your implode function is failing. There is no array to implode. Post the code for your form. Quote Link to comment Share on other sites More sharing options...
tomtom Posted July 29, 2008 Author Share Posted July 29, 2008 <?php if(!$_POST[installation]) { echo " <div style=\"display: none;\" id=\"products\"> <div style=\"overflow: auto; height: 150;\";> <form method=\"post\"> <table>"; $get_produc = mysql_query("SELECT * from `products`"); while($product = mysql_fetch_array($get_produc)) { echo " <tr> <td><input type=\"checkbox\" name=\"check[]\" value=\"" . $product['id'] . "\""; if($product['rec']=="yes") { echo " checked disabled"; } echo ">" . $product['name'] . "</td> </tr>"; } echo " </table> </div> <input type=\"submit\" name=\"installation\" class=\"sub\" value=\"Install\"> </form> </div>"; }else{ echo "<div id=\"install\"><center><img src=\"/delta/modules/ajax-loader.gif\"><br> <b>Installing...</b> (May take a few minutes)</center></div> <body onload=\"HideContent('install');\">"; print_r($_POST['check']); $product = implode("/", $_POST['check']); // rest of code etc... ?> But it can't be that it isn't submitting. As if I add another input field, that posts perfectly fine. And the form does submit. It just errors on the checkboxes :S Quote Link to comment Share on other sites More sharing options...
tomtom Posted July 29, 2008 Author Share Posted July 29, 2008 I know what the problem is!! Right. It was getting this error because there were NO values submitted. Ones which were like this... <input type="checkbox" name="check[]" value="13" checked disabled>Icon manager Did not submit any value but normal ones withOUT checked or disabled and were ticked, did submit - therefore fixing the error. It's the disabled that interferes. If it is set as disabled it sends nothing. Solved 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.