Jump to content

uniflare

Members
  • Posts

    867
  • Joined

  • Last visited

Everything posted by uniflare

  1. I would like to know why I have been given this warning: uniflare, You have been given a warning by .josh. Reason: Other Not trying to be anal but... You've been a member for almost 4 years, and have almost 1k posts...I think you should know by now to use code tags in your posts! .josh. I am pretty sure i use code tags. always, maybe i forgot. To that end, I will not be helping on this forum anymore. A warning for not posting code tags? wtf? I couldn't post unless i "acknowledged" the warning. This is like school. I have helped people on here because i like helping. not to be a part of some crazy mans empire. Maybe i just forgot to use code tags, and i get a warning like that, this forum is dead to me because of this admin. Bye bye
  2. Just read a warning about not formatting my post... wtf??

  3. $strings = array(); // sample data $letters = array(); $numbers = array(); foreach($strings as $str){ if(preg_match("#([a-z]*)([0-9]+)#i", $str, $matches)){ $letters[] = $matches[1]; $numbers[] = $matches[2]; } } print_r($letters); print_r($numbers); Preg match is very handy, would be quicker to use on blocks of text rather than single elements in a loop. (for text though use preg_match_all, slight differences)
  4. ah i see what youve done. Please explain code, and neaten it up lol - wrap your code in bb tags so its easier to read, but make sure it starts with a <?php. eg: [ code] <?php //some code ?> [/ code] --- basically, you make a php script called "getimg.php", you make it get an image from the database according to an paramters you give it via the URL, eg: getimg.php?img=fduiowehr9832 could be a lovely picture of your dog. After that, you ust change your current page so that ou put that link in there.
  5. sorry, if you are looking for php help then sure. HTML help is everywhere else. --- google "editable list box"
  6. Are you sure you are the author of this code? It ust seems you lack the knowledge to of got this far; The error your getting is because you are calling a class method/function "if ($theValidator->foundErrors())" if this method is not in "SystemComponent.php" i the "systemcomponent" class then you need to add it and make it do what you want it to do. === The error is pretty self explanatory, you cant use a method that hasnt been made/set.
  7. Arras are really simple once you get into them, and you cannot code without them . <?php $disallowed = array( "at", "the", "a", "or", "and" ); // and about 1 hundred other words lol. ?> then you may need a more advanced regex pattern, to use "preg_replace". Ask in the regex forum for help with that, something like: "/\A[ ]{0,1}".$current_word."[ ]{0,1}$/i" - this should work, but there might be more effective methods. My Example: <?php $disallowed = array( "at", "the", "a", "or", "and" ); // and about 1 hundred other words lol. //set string $string = $_POST['search']; // $_POST from form data. //loop foreach($disallowed As $current_word){ $string = preg_replace("/\A[ ]{0,1}".$current_word."[ ]{0,1}$/i"," ",$string); } echo($string); ?> The aim is to not leave half a word, eg: if ou searched for 'sweat', and ou filtered 'at', ou would be left with 'swe'. So you need a regex pattern that could handle that. or use a different method - like splitting the string into an array itself and remove specific values. - uniflare
  8. the function doesnt exist: foundErrors()
  9. the error is here: DJInfo= "This text is updated"," WHERE id = "1" rid urself of the ," <?php // Add this code, mysql_real_escape_string basically prevents SQL injection when working with insertion etc. Foreach($formVars As $Key=>$Value){ // So, this will loop each form variable, and temprorarily set the $key to the name of the variable, and $Value to the... value.. // This basically sets variables from the formvars array, $formVars['name'] will become $name, and so on.. $$Key = mysql_real_escape_string($Value); } // Change the query to a more standard structure. And remove the error mentioned above. $query="UPDATE `showinfo` SET `ShowName`= '$ShowName', `DJ`= '$DJ', ` Day`= '$Day', ` StartTime`= '$StartTime', ` EndTime`= '$EndTime', ` ShowDesc`= '$ShowDesc', ` DJInfo`= '$DJInfo' WHERE `id` = '$id' "; ?> hope this helps
  10. You will notice in the query it gives the "where id='' " should be something like, "where id='1' ". So its missing the ID for the ROW to update, so it doesn't update any, but it doesn't error, so. You need to add a "Hidden" type of input field: <input type="hidden"> with a value as the ID of the record that is being modified; [] Add this line into showupdate.php <?php /* This adds a "hidden" input field onto the form, (must be between <form> tags) */ ?> <input type="hidden" name="id" value="<?php echo($formVars["id"]); ?>">
  11. If you can just post "postupdate.php", should be able to work from there . Try changing: <?php //... $query="UPDATE showinfo SET ". "ShowName= \"".$formVars["ShowName"]."\",". "DJ= \"".$formVars["DJ"]."\",". "Day= \"".$formVars["Day"]."\",". "StartTime= \"".$formVars["StartTime"]."\",". "EndTime= \"".$formVars["EndTime"]."\",". "ShowDesc= \"".$formVars["ShowDesc"]."\",". "DJInfo= \"".$formVars["DJInfo"]."\",". "\" WHERE id = \"".$formVars["id"]."\""; mysql_query($query); mysql_close($db1); //... So you can debug it like this: <?php // ... $query="UPDATE showinfo SET ". "ShowName= \"".$formVars["ShowName"]."\",". "DJ= \"".$formVars["DJ"]."\",". "Day= \"".$formVars["Day"]."\",". "StartTime= \"".$formVars["StartTime"]."\",". "EndTime= \"".$formVars["EndTime"]."\",". "ShowDesc= \"".$formVars["ShowDesc"]."\",". "DJInfo= \"".$formVars["DJInfo"]."\",". "\" WHERE id = \"".$formVars["id"]."\""; // First DEBUG, check out what the query looks like: echo("<br />$query<br />"); mysql_query($query) or die ($query."<br />".mysql_error()."<br />"); // an OR DIE() is always useful to catch those simple mysql logic errors mysql_close($db1); // do not need this line unless you are connecting to different mysql host servers. // ... Tell us what it says, and we can work backwards from there .
  12. Any "Confidential" or "Restricted" files should always be put outside of the public root - that is: Typical SYSTEM path to web server public root: /home/web/www Translates to: http://www.some-website.com/ The public root being the folder "www", so if you store all your files in "/home/web/securefiles/" no one can access the folder anyway - Apache wont let them, but your php script has no problem serving the file itself, including files, or manipulating them.
  13. yes, you can change the pattern to validate emails etc as well. Do a google search for "preg_match validate form data"
  14. \A is the same as ^, Thge difference is ^ is like "At the start of this line". \A is like "At the very start of $subject". So if your matching against a multilined string, eg: this is [illegal ch4rs] a multiline blah blah so if u used ^, it would match ok since it would match line 2 and 3, but obviousl you dot see line 1. if you used \A, it would fail, since it spotted illegal characters o the first line. (it interprets it as a single lie, rather than multiline.) php.net/pcre for more information.
  15. It is because you named your column "like", this is very bad naming issue since mysql has a control clause name LIKE, either, do this: $query = "UPDATE `beloved_sonic_charac` SET `like`=(like+1) WHERE `id`='$PollItem';"; or rename your like column to something better (recommended)
  16. ok try this instead: (for the update query): $query = "UPDATE `beloved_sonic_charac` SET `like`=like+1 WHERE `id`='$PollItem';";
  17. You want to add 1 to the items that have bee checked ON, or OFF? (ticked, or unticked) And no that code was to explain what i meant about using the KEY rather than the VALUE to get the ID number. if the query isnt working, echo the query like so: <?php foreach($_POST['POLL'] As $PollItem=>$PollValue){ $query = "UPDATE `table` SET `column`='(table.column + 1)' WHERE `id`='".$PollItem."';"; echo("ID NUMBER: $PollItem --- QUERY: ".$query."<br />"); // add this line here. give us what it says $result = mysql_query($query) or die ("ERROR: ".mysql_error()."<HR>".$query); } ?>
  18. always put the - (hyphen, dash, whatever) at the END of the expression set; You also have an extra hyphen between the A-Z and 0-9 parts, you dont need one there. or want one there. Fixed Expression: eregi("^[a-zA-Z0-9_ -]{4,20}$ ", $testName) Also, i would use preg_match (i think its faster lol). // i = Case-INsensitive, matches A-Z as well as a-z. \A = Start of subect, regardless of multiline mode. preg_match("/\A[a-z0-9 _-]{4,20}$/i",$testName); Hope it helps PS: Preg_Match expressions require you wrap the REGEXP i forward slashes, or another compatible sybmol, these are the start and end of the expression, there are "modifiers" that are put on the end of the expression, liek the "i" above which makes the match, case-insensitive. Though modifiers are not required, the forward slashes are.
  19. He is trying to explain "Literal" Strings in php. Nice catch landavia. Basically; Any string enclosed in single quotes ', will NOT 'parse' variables and functions inside the string; as it is taken.. "Literally". For Example; $variable = "not"; $teststring = 'This string will $variable parse'; // Echos: This string will $variable parse $variable = "not"; $teststring = "This string will $variable parse"; // Echos: This string will not parse. (but it does, obviously) To use variables inside a literal string you must use "Concatenation"; eg: $teststring = 'This string will '.$variable.' parse'; // Echos: This string will not parse. (but it does, obviously) Hope it makes sense. Now to fix your script. If you were to start all over again, ask the same question you did when u started, i would tell you this; Change this: <?php $recentchara = 0; $reschara = mysql_query("SELECT id, nme, approv FROM beloved_sonic_charac WHERE approv='1' ORDER BY nme ASC")or die( mysql_error() ); while( ($chara = mysql_fetch_row($reschara)) && $recentchara < 100 ){ $recentchara = $recentchara + 1; echo "<input type='checkbox' name='$chara[0]'> $chara[1] <br>"; } to this: <?php $query = "SELECT id, nme, approv FROM beloved_sonic_charac WHERE approv='1' ORDER BY nme ASC LIMIT 100"; // Limit to 100 results rather than using extra variables. $result = mysql_query($query)or die( mysql_error() . "<HR>".$query); // Execute Query Seperately while($chara = mysql_fetch_row($reschara)){ echo "<input type='checkbox' name='POLL[".$chara[0]."]'> $chara[1] <br>"; } // So this will create the entire checkbox form. Sorted, now to save these puppies. The page where the form is submitted: <?php foreach($_POST['POLL'] As $PollItem=>$PollValue){ $query = "UPDATE `table` SET `column`='(table.column + 1)' WHERE `id`='".$PollItem."';"; $result = mysql_query($query) or die ("ERROR: ".mysql_error()."<HR>".$query); } ?> Hope this helps you out. And i hope you understand whats going on. The checkboxes are all in an array "POLL". Basically the checkboxes only exist in POST data if the checkbox has been ticked (or selected), so, the only checkboxes that will end up in the POLL array are the ones that are checked. (which are the ones you want to update). So all you do loop through each POLL item, and update accordingly. Just remember the `id` for that checkbox is the Array KEY, NOT the VALUE. $array = array( "KEY" => "VALUE" ); Voila.
  20. I'm interested to see how much faster this would be: (Since putting functions if loop statements gets executed each time ) <?php $test = 'Paths.Images.Icons'; $rVerse = array_reverse(explode('.',$test)); foreach ($rVerse as $v) $out = array($v => $out); print_r($out); ?> maybe slightly faster?
  21. M code is fine, it works, if you can use it or dont know how dont tell me its wrong!! it really gets on my nerves when people say the code is completely wrong when they dont even copy it right.... A) First: its not $PollValue... READ my post - its $PollKey !!. Second: if $PollValue = 111; The nthe query you just gave would work "Flawlessly", it would add 1 to the row with the id 111, which should be one of the checkboxes he checked. ok? ---- B) This is a BURN - Consult my signature! == PS, what is: wakakakaka? -- There is more to FLAME you for but i cba...
  22. foreach($_POST['POLL'] As $PollItem=>$PollValue){ mysql_query('UPDATE `secrett1_artgallery`.`beloved_sonic_charac` SET `like` = (like +1) WHERE `beloved_sonic_charac`.`id` =\'$PollValue\' LIMIT 1'); } You did not escape the single quotes around $PollValue.
  23. Looks quite simple really. The structure would be: FORM_ <form action="" method="post"> <input type="checkbox" name="POLL[id_number]">id_name <Br /> <input type="checkbox" name="POLL[id_number2]">id_name2 <Br /> <input type="checkbox" name="POLL[id_number3]">id_name3 </form> You can generate something like this eg: echo "<input type='checkbox' name='POLL[".$chara[0]."]'> $chara[1] <br>"; So, when you get these result on the next page, you would loop the "POLL" array, eg: foreach($_POST['POLL'] As $PollItem=>$PollValue){ // update $PollItem add 1 etc. ($PollValue will always be "on" or w/e). } Hope this helps
×
×
  • 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.