Fukushousha Posted May 30, 2008 Share Posted May 30, 2008 Hello all.Remembers the checkboxes problem I had. Well even though it is solved and is working by having grouped checkboxes together with arrays I still have a minor problem.If the user does not select any of the checkboxes of a said group I do get an undefined index notice(not an error).For example : //if we got any checked grp1 if(sizeof($_POST['grp1']) > 0) loopthroughchecks($_POST['grp1'],"tablename",$user); I tried to do this with a sizeof check ... but it can't be zero or null, since it exists if and only if the user has checked any boxes. So to avoid getting that annoying "Notice: Undefined index: " how can I do it? How can I check if it exists or not without getting a notice?EDIT: Also another completely unrelated question. Say I got in $conn a persistent sql connection returned by mysql_connect($chostname, $cusername, $cpassword ). How can I check if $conn is still active? Or if I need to reconnect? Link to comment Share on other sites More sharing options...
Wander Posted May 30, 2008 Share Posted May 30, 2008 instead of if(sizeof($_POST['grp1'])>0) u can use if(isset($_POST['grp1'])) to see if any of the checkboxes is set$conn usually just stais active till the end of the script, but if u wanna check i think if($conn) would work, but not sure what happens when the connection closes during a script Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 30, 2008 Share Posted May 30, 2008 If you really need to know what happens if the connection closes, try mysql_close($conn) and print the result of if($conn). (If $conn was created with mysql_pconnect, this won't work.) EDIT: But mysql_connect will retrieve the old connection if it exists. Link to comment Share on other sites More sharing options...
Fukushousha Posted May 30, 2008 Author Share Posted May 30, 2008 Hmm I see. Okay guys, thanks you have been really helpfull. Especially the isset() function .. I did not know it existed >_< Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.