Jump to content

laffin

Members
  • Posts

    1,200
  • Joined

  • Last visited

Everything posted by laffin

  1. yes, checkboxes dun return a $_POST variable if not checked so best way is the isset method.
  2. Use a flatfile, and limit the amount of lines stored in the file its the easiest way. you can put the file off the web folder, so no one can access it or use .htaccess to deny access to that folder If not done this way, u need a full time service in order to keep all the data in memory. php just runs when requested to run, so u need to store the info u get from chat somewhere, when its not being requested.
  3. Well this logic don't make send ? if ($inv['userid'] != $id && $inv['useremail'] != $useremail && $inv['hash'] != $hash){ ?> !!ERROR!! <?} else { ?> <? require("inc/signup.php");?> <?}?> the first if statement, everything must fail to get an error. Which shud be if anyone of them fails than error out. the way to do this, is to check if they all pass. than throw a ! which does wut ya want, if any field fails if (!($inv['userid'] == $id && $inv['useremail'] == $useremail && $inv['hash'] == $hash)){ ?> see the differences now Hope that helps
  4. I was building an invite system But I wanted to be able to track the invites (user invites and open invites) So I thought about javing a db with a number of fields. I think my fields were like id INT AUTO_INCREMENT code char(32) NOT NULL added TIMESTAMP start_date TIMESTAMP end_date TIMESTAMP amount TIMESTAMP default 1 count int referrer int the code was an md5 code. added is when the invite code was created start/end dates how long the invite code is good for (0 out for forever) amount number of invites allowed with this code count is the amount counter (or if single invite, if it has been used already) referrer is the user id who created the invite if referrer was specifies amount is 1 and I gave them 30 days to respond but if I wanted to, I cud create a code and post it on a board as a promotion, this is where amount is used. the userbase I did add a field of invites, which was earned through board activities (or given by other users). which was just a number of invites they have, u can make this refresh after a period of time instead. For me, when starting any project. Ya have to look at how ya want it to work, and look at the data ya will need. Work from the database first, then work on the code. Anyways good luck with this
  5. It's packaged with a lot of unix/linux operating systems. and there is a windows version, as is a bunch of unix tools.
  6. I've done something similar to this a number of years ago. Had a couple of different form fields. validation and stuff it still was a bit rough, but I left it as is as it did wut it did magnificently. I made it to maintain a config file. u can browse the source at sourceforge tbdev.net It shud provide some ideas on creating a more robust form creator
  7. Just dun worry about learning it all. as with C/C++ u dun need to learn the functions libraries. learn the basics of the language. after u get the basics of the language, than delve into using the functions that u need. Yes, there are gonna be times, when u will replicate a function that already exists. and ya can tell yerself, that u know how it can be done, u know how it works. there are too many ppl that rely on prebuilt code, yet have no clue how that code works.
  8. Actually there is but its a lot more coding. I have something like that which is approx 90% complete, but had to stall on the development of the code. wut u end up doing is parsing the bbcode tags individually and build up a stack. and when u encounter a end tag, u pop it off the stack and process the tags. nice thing, if done using a stack, is that it dusnt get confused about which are the matching end tags. FIFO stack. but it is a lot of extra coding, because you are building this stack. Than a new problem arised, wut to do with mismatched tags. Anyways good luck if u want to proceed in building a stack based bbcode parser, I can help (More like point u in right direction than providing code)
  9. I wud prefer option 1 Even better is if u can store the questions into a table and the test names into another table This way, u can add more tests / questions. Of course u would have to devise a way of saying which questions are of which type bool (yes/No, True/False) Single Anser options Multiple choice essay But that gets its own complexities. But in the end shud prove very flexible.
  10. I never used eregi functions, I stick with pregmatch functions preg_match('@.*?\((\d*)\)@',$_POST["Venue{$i}"],$match); ${"Venue$i"}=$match[1]; Shud work
  11. or as he asked check the ini <?php if(!empty(ini_get('smtp')) mail($a,$b,$c,$d); this means just see if smtp php.ini variable is not empty but again this can also be 'sendmail_path' for linux systems
  12. I prefer to use AdRocks suggestion.
  13. Correct take a simple form like for($i=1;$i<10;$i++) { $val=$i*10; echo "<input type=\"hidden\" name=\"box[{$i}]" value=\"{$val}\""; } echo "<input type=\"hidden\" name=\"box[{$i}]" value=\"\""; very simple form, for readability. okay in processing u can now treat $box as an array <?php $boxes=$_POST['box']); $count=count($boxes); echo "Found {$boxes} boxes<BR />"; $removed=0; foreach($boxes as $idx=>$box) { if(empty($box)) { unset($boxes[$idx]); $removed++; } } echo "Removed {$removed} empty boxes<br />"; Just to give u an idea
  14. sample code <?php function my_escape($string) { return is_int($string)?$string:("'" .mysql_real_escape_string($string) . "'"); } $updates=array(); $fields=array('username','password','email','im'); foreach($fields as $field) { if(isset($_POST[$field]) && !empty($data=trim($_POST[$field]))) $updates[$field]=$data } $update_fields=array_keys($updates); $values=implode(',',array_map('my_escape',$updates)); $fields=implode(',',$update_fields); $query = "UPDATE users ({$fields}) VALUES({$values}) WHERE id={$id}"; Work through the logic You will get it
  15. Just a side note, the easier way of doing this is using an array for $PlayerNo this can be achieved by using brackets in your form fields for ( $counter = 1; $counter <= $PlayerNo; $counter += 1) echo " <input name=\"Position[$counter]\"> <input name=\"Points[$counter]\"> <input name=\"MembershipNo[$counter]\"> "; } Now since the variables are in an array you can use foreach or count
  16. php processing are limited to a specific amount of time for execution. Usually 30 secs. if this is a big download, u will either need to increase the amount. Also wget can resume downloads
  17. Glad you caugt it now Congratz
  18. u can use a nested if statement or have an elseif the elseif statement first if isset($_GET['category']) && isset($_GET['subcategory'])){ // blah blah } elseif isset(_$GET['category']) { // blah blah } else { // blah blah } Look as to why we have category and subcategory and understand why we have it above just plain category. but in this instance, i wud prolly nest my ifs instead if isset($_GET['category'])) if(isset($_GET['subcategory'])){ // blah blah } else { // blah blah } } else { // blah blah } Have fun Note that MrMarcus' code will fail the second if statement, as I stated its a pitfall, and never execute the 2nd if statement.
  19. mysql_query("UPDATE counters SET num = num + 1 WHERE name='count'") look at the previous queries they all reference the content again, not the field names. you have 2 field names, name and num. not count, onum, cnum... these are the contents of the field name so u have to tell MySQL what field yer updating and which row. The field yer updating is 'num' where the row has field 'name' contains 'count' Again yer table has no 'count' field, this is where yer misunderstanding go through yer code again, and look if you can fix the rest its easy after ya get the hang of it
  20. and why are u comparing against a space? if (empty(trim($_POST['MembershipNo1']))){ but these are dynamic fields, why not have them in a loop instead as yer form does? for ( $counter = 1; isset($_POST[($mc='Membership'.$counter)]); $counter += 1) if (empty(trim($_POST[$mc]))){ we want to check for an empty response, trim just removes any whitespaces
  21. I was making a statement, yer SQL statement was wrong. as it was referencing the contents of the fields, instead of referencing the fields themselves. The field names are the headers in this table. Not the contents. look at the sql I provided above. That shud do wut u want.
  22. Yes and wut exacly are you trying to do. MySQL needs to know which record you are refferring to and how. but if your trying to grab all records into an array. than you will have to loop $count = mysql_fetch_row(mysql_query("SELECT num FROM counters WHERE name='count'")); so you have to follow what yer field names are here we just tell it, we want field 'num' from counters WHERE name is 'count'
  23. ahhhh, but dun give up. I knew C before i got started, that helped a lot in learning php. But I got very interested in an open source project. and started making mods for it. It took like 3 months from writing small mods to big huge ones. and a few bookmarks and tools to help. an editor which has code folding, syntax highlighting, and tooltips. Currently using PHPDev (Sourceforge) for an editor as it does these basic things, also hitting f1 takes you to the help page of the function at php.net. a list of good sites, most often as I said php.net answers my questions, or I look at questions here, great place to learn. and dont forget to keep yer code beautiful, indent ... indent ... indent Keeping it beatiful can save u countless hours of debugging a script (especially for unbalanced {} () '' ""). [url=http://thephppro.com/tools/beautify.php]PHP Beautifier for ugly code Good luck
  24. shud be }if ($detalles == "") { { and } denotes a block of code. so these must come in pairs (cant have } without a {) the mail function
  25. Learn to use ' single quotes and " double quotes u use " double quotes all over, yet still continue with the string. ' single quotes dun do $string processing within the quoted string " double quotes process $string variables within the string and also provide character substitution. it dusn look like u are processing any variables or special characters in yer echo's so replace the " double quotes to ' single quotes to mark the begin and end of yer string
×
×
  • 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.