Jump to content

Lodius2000

Members
  • Posts

    586
  • Joined

  • Last visited

    Never

Everything posted by Lodius2000

  1. can items in the $_POST array be array? if so would they be accessed by $_POST['item]['sub_item'] thanks
  2. im out, I dont do games, nothing against them, just not for me
  3. gotta be more specific there are countless ways to use select, update is a bit more narrow in its variations and alter, to me is for changing the structure of tables, least thats how I use it do you have phpmyadmin, if so use it and see what the sql it uses looks like, anytime you change anything it prints out the sql it used when the page reloads
  4. limit $words = explode('|', $wordlist); takes the | lines out for you leaving you with an array $words = array(crap:cr*p, dang:d*ng, shoot:sh**t);
  5. that worked but why would taking element name out of $values do it, Ive used this function as i posted it a thousand times and never had a problem
  6. k now im really confunded <?php //print a text box function input_text($element_name, $values){ print '<input type="text" name="' . $element_name .'" value="'; print htmlentities($values[$element_name]) . '"/>'; } $wordlist = "crap:cr*p|dang:d*ng|shoot:sh**t"; $words = explode('|', $wordlist); foreach ($words as $word){ $word = explode(":",$word); $new_words[($word[0])] = $word[1]; } print '<form name="create" method="POST" action="'.htmlentities($_SERVER['PHP_SELF']). '">'; foreach($new_words as $word => $replacement){ input_text($word,$word); print "\n \n"; input_text($word,$replacement); print "\n<br />\n"; } ?> prints <form name="create" method="POST" action="/Users/imaging/Desktop/TacoHTMLEditTemp.php"><input type="text" name="crap" value="c"/> <input type="text" name="crap" value="c"/> <br /> <input type="text" name="dang" value="d"/> <input type="text" name="dang" value="d"/> <br /> <input type="text" name="shoot" value="s"/> <input type="text" name="shoot" value="s"/> <br /> why is each value only the first letter?
  7. I am taking this thread (http://www.phpfreaks.com/forums/index.php/topic,225600.0.html) in a new direction so i started a new thread i am still in the theory part here I have a list of bad words and their replacements, I explode on | then explode on : Run the script i have here, the second foreach just prints out as 'Array' $wordlist = "crap:cr*p|dang:d*ng|shoot:sh**t"; $words = explode('|', $wordlist); foreach ($words as $word){ print "$word<br>\n"; } print "<br>exploded on :<br>\n"; $on_colons = explode(':', $words); foreach ($on_colons as $on_colon){ print "$on_colon<br>\n"; } I want it to print out as foreach ($on_colons as $on_colon){ print "$on_colon[array_key], $on_colon[array_value]"; } EDIT: so that each line would read 'crap, cr*p' and so on //end edit i am lost on how to do that Thanks
  8. limitphp, if we want relacement control lets use the code i quoted above, then make a form that explodes the list on | and then explode it again on : then feed them into text fields, so you can change them, to whatever you want you would have a list like these would be in text fields Jerkwad J*rkw*d but if you decided J*rkw*d was too revealing you could change it to J**kw*d, also, always have the script make a blank set of fields at the bottom so you can add a new one, incase somebody slips a new word in there. since there is a true plethora of curse word derivitives and all. then upon post, reconstiute the string with the : and | characters then rewrite the file. the beauty of this is that your banned word list is truely customizable with how they display, it doenst just take out the vowels, you can ban whole words, you can change it to *REMOVED* if you thing it is that raunchy, and your list of words could start with just the basics, and be constantly growing, as long as you are active in your comment thread readings and your comment system has flag and edit functions you can do your edit and then go add it to the list I know, lots of reading, but it could work EDIT: thanks for starting this thread, i have been trying to do this for a while but am terrible with regex, so these expressions are really helping me out
  9. chronister, look into that book i talked about earlier 'learning php 5' his method is really nice, makes functions for form processing... simple validation lines and all sorts of goodies. heres the main page logic for all my form pages, just put this at the top and then build all the functions <?php if($_POST['_submit_check']){ //$_POST['_submit_check'] is a hidden field, makes redisplay possible if($form_errors = validate_form()){ show_form($form_errors); } else { process_form(); } } else { show_form(); } function show_form($errors = '') { // make the form here //start with if ($errors){ print 'Please correct these errors: <ul><li>'; print implode('</li><li>', $errors); print '</li></ul>'; } } function validate_form(){ //contains simple validation like //check that username is entered if (trim(strlen($username)) == 0) { $errors[]= "You must enter a username."; } } function process_form(){ //what do you want to do with the entered data, whatever it is, do it here } ?> that make sense?
  10. sorry ryy, didnt see your response, yeah it should be that easy, I dont think pear modifies any settings files (php.ini) or such because it doesnt ask for those locations, so drag and drop should do it, let me know though I am interested to know if it works
  11. yesideez, cant take credit for that one, got that code verbatim from learning php 5 by david sklar, but man does it help
  12. everybody is gonna hate me for just giving you code, but you have a thousand posts, you could do this if you really wanted to, it doenst help with validation, but man does it make forms a whole lot easier formhelpers.php <?php //print a text box function input_text($element_name, $values){ print '<input type="text" name="' . $element_name .'" value="'; print htmlentities($values[$element_name]) . '"/>'; } //print a title box, like text box but as wide as a text area function input_title($element_name, $values){ print '<input type="text" size="76" name="' . $element_name .'" value="'; print htmlentities($values[$element_name]) . '"/>'; } //print a password box function input_password($field_name, $values) { print '<input type="password" name="' . $field_name .'" value="'; print htmlentities($values[$field_name]) . '"/>'; } //print a submit button function input_submit($element_name, $label){ print '<input type="submit" name="' . $element_name .'" value="'; print htmlentities($label) . '"/>'; } //print a textarea function input_textarea($element_name, $values){ print '<textarea cols="75" rows="40" name="' . $element_name .'">'; print htmlentities($values[$element_name]) . '</textarea>'; } //print a radio button or checkbox function input_radiocheck($type, $element_name, $values, $element_value){ print '<input type="' . $type . '" name="' . $element_name . '" value="' . $element_value . '" '; if ($element_value == $values[$element_name]){ print ' checked="checked"'; } print '/>'; } //print a select menu function input_select($element_name, $selected, $options, $multiple = false){ //print out the <select> tag print '<select name="' . $element_name; // if multiple choices are permitted, add the multiple attribute // and add a [] to the end of the tag name if ($multiple){ print '[]" multiple="multiple'; } print '">'; //set up the list of things to be selected $selected_options = array(); if ($multiple) { foreach ($selected[$element_name] as $val){ $selected_options[$val] = true; } } else { $selected_options[ $selected[$element_name] ] = true; } //print out the <option> tags foreach ($options as $option=>$label) { print '<option value="' . htmlentities($option) . '"'; if ($selected_options[$option]){ print ' selected="selected"'; } print '>' . htmlentities($label) . '</option>'; } print '</select>'; } ?>
  13. depends what does mac os tiger ship with, in the mean time ima run php_info ... edit: shite, 4.4.7
  14. im working on learning oop through an online tutorial its talking about public, proected and private right now and i am getting an error that doenst match what the tutorial says i should be getting Fatal error: Cannot access private property person::$pinn_number in ... instead i am getting Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /Users/imaging/Desktop/oop/class_lib.php on line 10 heres my code class_lib.php <?php class person { var $name; public $height; protected $social_insurance; private $pinn_number; function __construct($persons_name) { $this->name = $persons_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?> index.php <?php include("class_lib.php"); $stefan = new person("Stefan Mischook"); echo "Stefan's full name: " . $stefan->get_name(); /* Since $pinn_number was declared private, this line of code will generate an error. Try it out! */ echo "Tell me private stuff: " . $stefan->pinn_number; ?> heres the tutorial but my code has been cut and pasted from there just to make sure i didnt have typo http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-3.php whats the problem thanks
  15. heheh touche, or too-shay, however that is spelled solved
  16. thorpe, i would be putting all the text on the image, the photo comes in precropped and sized, then the text is added to it and saved anew, figure the calender would be chosen by month and year dropdowns and then the credit would be text field
  17. again yes or no, can this be done in php and please rate 1-10 of difficulty I dont know what would be involved, but I do think it could be done, but wanted to make sure //see attached image [attachment deleted by admin]
  18. pear dumps everything in one directory, that you choose, just install it locally then copy it all to your server, should work
  19. Lodius2000

    Help

    EDIT: regex is your best bet, query the db for all results, run a preg_match and foreach the results but im terrible at regex so dont ask me //dunno why this got moved
  20. Lodius2000

    Help

    my brains not working tonight but heres a couple of ideas -regex in the query identifying the first character as numeric or not (not for sure if mysql supports php regex) - return all the movie titles and shorten them all to 1 character and run is_numeric() on them, but, im really tired and cant remember how to shorten a string, nor can i figure out how to get those results back to the query to get you the right movie titles in their entirety //should get you thinking EDIT: regex is your best bet, query the db for all results, run a preg_match and foreach the results but im terrible at regex so dont ask me //dunno why this got moved
  21. Lodius2000

    Help

    if you mean database (mysql) column names that start with numbers... you dont, db columns, like php variables cant start with numbers
  22. ok thats what i was envisioning <?php //to get how may people answered what $excellent = mysql_query("SELECT question_1 FROM table WHERE question_1 = 'Excellent'"); $excelllent_count = count(mysql_fetch_assoc($excellent)); //to get total number of responses $total = mysql_query('SELECT question_1 FROM table'); $total_count = count(mysql_fetch_assoc($count)); $result = ($excellent_count/$total_count)*100; printf( "%2d\% of people think question 1 is excellent"); // the \% should be displayed as a % sign, but im tired, might require tweaking ?> that is how to do 1 answer for 1 question, $total of course is reusable for all answers to the same question, there are definately better ways to do this but I think it will work, though untested, oh and it will not round up or down on the percentages, so there is the possibility that your percentages wont add up to 100 i use a dba so using mysql_fetch_assoc might not be necesary but i dont think it will hurt either, guess you could replace count(mysql_fetch_assoc( with mysql_numrows.....Im tired
  23. Robert, I think a bit more info about your database is needed, I have stuff flying through my brain, because I think i can see what you need, but before I give you anything, i would like to know more about the structure of your db so that i dont get you all confused
×
×
  • 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.