Jump to content

danthethug

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

danthethug's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=374082:date=May 15 2006, 02:39 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ May 15 2006, 02:39 PM) [snapback]374082[/snapback][/div][div class=\'quotemain\'][!--quotec--] that would suggest that $checkboxarray3 is not an array, so backtracking a bit it also could mean $_POST['delid'] is not an array either. if 'delid' is a group of checkboxes, as with your other example, make sure you've got them set up with the [] as before <input name="delid[]" etc etc etc it could also mean that the condition you're checking for here: [code] if ($del) {    $checkboxarray3 = $_POST['delid']; [/code] is not actually being met, which is the most likely answer considering i can't see where $del is being set in the first place. with the above code, basically you're saying that if $del is 'true' or a non-zero value, set up the $checkbox3array and then do a 'foreach' on it. but if $del is false or a zero value, then you dont set up the array but run the foreach anyway. hope that helps cheers Mark [/quote] Yep it does, Ima try to check and see if its getting the ID of the messages to the Variable. Below is where it is defining the Variable $delid: [code] <input type="checkbox" name="delid[]" value="<? print "$wep[Id]"; ?>"> [/code] Thats just a snippet. Ok, Ive figured the problem out, (D' oh) I had forgotten to allow the <form method="post"> to be above the checkbox to carry the information. [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]
  2. I have a new problem relating a Message Center ive added awhile ago. Im trying to implement the Checkbox Arrays with this. Im getting the following error: Warning: Invalid argument supplied for foreach() in /home/nuke/public_html/Reloaded/message.php on line 12 Here is the PHP Code: [code] <? if ($del) { $checkboxarray3 = $_POST['delid']; foreach ($checkboxarray3 as $value3) {    $sql3= "DELETE FROM `Mail` WHERE Id='$value3'"; mysql_query("$sql3"); } print "Deleted"; } ?> [/code] Line 12 is right where foreach() is. I dont know whats wrong with it, Seems just fine but its not working.
  3. Thank you all, I tried the example redbullmarky had given me which was: [code] $sql = "delete from users where "; $checkboxarray = $_POST['remove']; foreach ($checkboxarray as $value) {    $sql.= "username = '$value' OR "; } [/code] I then edited the code to fit my needs but it Still didnt work so i did the following: [code] $checkboxarray = $_POST['remove']; foreach ($checkboxarray as $value) {    $sql= "DELETE FROM `User_Hitlist` WHERE ID='$value'"; mysql_query("$sql"); } [/code] And that worked out fine, Thanks again all. I loved the fast replies, Will be back when i have another problem :).
  4. [!--quoteo(post=373727:date=May 14 2006, 09:26 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ May 14 2006, 09:26 AM) [snapback]373727[/snapback][/div][div class=\'quotemain\'][!--quotec--] the principles i showed you should set you on your way. all you've got to remember is that array is nothing more than a group of variables grouped together with a common name. look at [a href=\"http://www.php.net/foreach\" target=\"_blank\"]http://www.php.net/foreach[/a] to get an idea of not just the 'foreach' command, but arrays in general. for something like what you appear to be doing, arrays of some form are going to be essential. [/quote] Ok, Will do and thanks for your help :-P
  5. [!--quoteo(post=373720:date=May 14 2006, 08:50 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ May 14 2006, 08:50 AM) [snapback]373720[/snapback][/div][div class=\'quotemain\'][!--quotec--] well put it this way. if you didnt have the [], you'd have to give each checkbox a different name, which would mean you'd have to process an unknown quantity of various variable names - eg $_POST['remove1'], $_POST['remove2'], etc, etc. not very dynamic. however - giving it the brackets [], you can give a group of checkboxes a single name and process them much easier. in my example, 'foreach' goes through each element of an array (automatic loop) and puts the value in $value, for easy reference. what my example does is builds up the query bit by bit - so you'll end up with something like: "DELETE FROM USERS WHERE username = 'thisuser' OR username = 'thatuser' etc etc". if you understand how arrays work, then all you need to know is that using the [] brackets forces a group of values into an array. in your case, you have an array called $_POST['remove'] where each element contains the VALUE of the checkbox that was checked. [/quote] Oh, I have horrible knowledge of arrays, but thats about it. Rofl, So all i use is the Example you provided me Above and just tweak it to fit my needs and that should work?
  6. [!--quoteo(post=371792:date=May 6 2006, 05:33 AM:name=Intelly XAD)--][div class=\'quotetop\']QUOTE(Intelly XAD @ May 6 2006, 05:33 AM) [snapback]371792[/snapback][/div][div class=\'quotemain\'][!--quotec--] Unfortunatly that doesn't work to :( But it has to be possible because in many newsletters there are links made with pseudoclasses... [/quote] I use CSS in my Email's Below is my Email code: [code] // subject $subject = '**** : Account Info'; // message $message = " <style> table{ border-collapse:collapse } body{ font: Verdana, Arial, Helvetica, sans-serif; color:#000000; } table{ font-family: Verdana; font-size:12px; } input { border:0px solid #cc0000; background-color: #000000; color: #FFFFFF } input.noborder { border:0px solid #cc0000; background-color: #000000; color: #FFFFFF } select { border:0px solid #cc0000; background-color: #000000; color: #FFFFFF } textarea { border:0px solid #cc0000; background-color: #000000; color: #FFFFFF } a:link{       color: #cc0000;     text-decoration: none } a:hover{       color: #cc0000;     text-decoration: none } a:visited{       color: #cc0000;     text-decoration: none } body {  font-family: arial; font-size: 10pt; color: #FFFFFF; background-color: #000000} table {  font-family: arial; font-size: 10pt; color: #FFFFFF} .normal {  border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px} .style1 {     font-size: 12pt;     font-weight: bold; } </style> <html> <head>   <title>**** : Text Based RPG</title> </head> <body> <CENTER><img src=http://www.**** .com/Reloaded/images/main.gif><BR><BR> Thanks for joining the fight son, Now logon with your credentials below and help out $side! <BR><BR> Username: $log<BR><BR> Password: $pass<BR><BR> Email: $email<BR><BR> Class: $Rank<BR><BR> </CENTER> </body> </html> "; // To send HTML mail, the Content-type header must be set $headers  = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: ****  Auto Register Mailing' . "\r\n"; // Mail it mail($email, $subject, $message, $headers); [/code] In that email i included my sites Header image, And PHP Variables. All you have to worry about is defining the Locations of things, Like the Img's and just tell it Variable Names, As for CSS its the <style>.....</style> So, Just try to put them around your CSS inside the emailing scripting. Then if that doesnt work try to tweak mine and see if that works. Other than that Email does the rest, I think anyhow. Lol.
  7. [!--quoteo(post=373712:date=May 14 2006, 08:04 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ May 14 2006, 08:04 AM) [snapback]373712[/snapback][/div][div class=\'quotemain\'][!--quotec--] that's because you have to treat an array as such. [code] $test = array('a', 'b', 'c'); echo $test; // output is 'Array' echo $test[1]; // output is 'b' print_r($test); // output is the full array [/code] so you need to go through each of your array elements and process them, for example: [code] $sql = "delete from users where "; $checkboxarray = $_POST['remove']; foreach ($checkboxarray as $value) {    $sql.= "username = '$value' OR "; } [/code] that should give you an idea cheers Mark [/quote] Well, now im kind of lost, You say i need to process each Array element. Well what im using this for is a MMORPG, and there could be 100 users, Does this mean id have to have 100 lines of this code? I also dont understand the $value part. Where is it pulling this from? QUICK EDIT: Is it pulling the $value variable from the HTML value="<? print "$wep[ID]"; ?>"?
  8. Hmm, Well i put it as just $remove on the SQL query and it returned Array as the Value. Im gonna try to force it into a POST and see if that works lol. Below is the entire page: [code] <? include "header.php"; $Check = @mysql_num_rows(mysql_query("select * from User_Hitlist where User_ID='$stat[ID]'")); ?> <center>     <table border="0.5" style="border-collapse: collapse" width="100%"  bordercolor="#999999">     <tr> <? if ($submit) { $check2 = @mysql_num_rows(mysql_query("select * from Users where Username='$hit'")); if ($check2 > 0) { ?> <td width="100%">Player added to hitlist!<DIV ID="dek"></DIV> <? mysql_query("INSERT INTO `User_Hitlist` ( `Username` , `User_ID` ) VALUES ('$hit', '$stat[Id]')"); } else { print "Sorry, No user found with $hit as username!"; } } ?> <? if ($subrem) { $check2 = @mysql_num_rows(mysql_query("select * from User_Hitlist where ID='$remove'")); if ($check2 > 0) { ?> <td width="100%">Player removed from hitlist!<DIV ID="dek"></DIV><? mysql_query("DELETE FROM `User_Hitlist` WHERE Username='$remove' AND User_ID='$stat[Id]'"); } else { print "Sorry, No user found with $remove as username!"; } } ?> <br> <div align="center">   <center>   <table border="1" cellpadding="2" cellspacing="0" style="border-collapse: collapse" id="AutoNumber1" bgcolor="#0E0E17" bordercolor="#FFFFFF">     <tr>       <td colspan="6">           <p align="center"><b>Hit List</b><br>                     (<? print "$Check"; ?> / <? print "$stat[MaxHitlist]"; ?>)       </td>     </tr>     <tr>       <td width="100%" colspan="6">       <table border="0" cellpadding="10" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber2">         <tr>           <td width="100%">                       <form method="post">           <p align="center">Username: <input type="text" size="20" name="hit">           <input type="submit" value="Add to Hit List" name="submit"></p>         </form>                          </td>         </tr>       </table>       </td>     </tr> <form method="post">     <tr>       <td width="150"><b>Name</b></td>       <td width="150" align="center"><b>Power</b></td>       <td width="150"><b>Hits</b></td>       <td width="150" align="center"><b>Remove</b></td>     </tr> <?     $wsel=mysql_query("select * from User_Hitlist where User_ID='$stat[Id]' order by ID+0 DESC ");     while ($wep = @mysql_fetch_array($wsel)) { $player = @mysql_fetch_array(mysql_query("select * from Users where Username='$wep[Username]'")); ?>           <tr>       <td bgcolor="#0E0E17"><a href="profile.php?id=<? print "$player[Id]"; ?>"><? print "$wep[Username]"; ?></a></td>       <td align="center"  bgcolor="#0E0E17"><font color="#00FFff"><? $Power = to_money($player[Power]); print "$Power"; ?></font></td>       <td bgcolor="#0E0E17"><? $Hits = to_money($wep[Hits]); print "$Hits"; ?></td>       <td align="center" bgcolor="#0E0E17"><input type="checkbox" name="remove[]" value="<? print "$wep[ID]"; ?>"></td>     </tr> <? } ?>               <tr>           <td colspan="3"></td>           <td align="center">               <input type="submit" name="subrem" value="Remove">           </td>       </tr> </form>   </table>   <br>   </center> </div>             </td>           </tr>                           </tr> </table> </td> </table> </table> </center> [/code] If that will help im not sure but most likely lol. QUICK EDIT: This is what i get when i change it around to the Variable name and value you suggested in your post. It gives the same error even if i had put just $remove. Sorry, No user found with Array as username!
  9. Hello, Ive been coding with PHP for quite some time now (2-3 years) and have gotten fairly far from my eyes. Anyhow, Ive never come across the use of this code snippet below of HTML: [code]       <td align="center" bgcolor="#0E0E17"><input type="checkbox" name="remove[]" value="<? print "$wep[ID]"; ?>"></td> [/code] Please ignore the php in that but the main question is, The name. Why does it have the [] after remove. This form is for multiple Checkboxes that will be used with just a few lines of PHP code to delete the Table Row of information dealing with $wep[ID]. I cant figure out how the [] is helping but i notice other forms that do the same thing this is doing using that, So just wondering how i might be able to use this feature also? [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] Thanks, Daniel.
×
×
  • 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.