Jump to content

Destramic

Members
  • Posts

    960
  • Joined

  • Last visited

Everything posted by Destramic

  1. thanks all for your replies...ive found something strange...ive used this function to add slashes before data is added to the database..it does the $_POST array and returns it with slashes as required..but when i call $_POST['name'] it will display with no slash...very wierd? it should have a slash infront of the single quote.. can anyone explain? thanks [code] function add_slashes($value) { // Check if string exists if (is_string($value)) { return addslashes($value); } elseif (is_array($value)) { return array_map('add_slashes', $value); } } //Add slashes add_slashes($_POST); print_r(add_slashes($_POST)); echo $_POST['name']; Array (     [name] => o\'really     [email] => destramic@hotmail.com     [error_type] => Broken Link     [reason_occurred] => test ) o'really [/code]
  2. thank you...in affect wouldnt using this script be goin back on your self? striping slashes. adding slashes (back to square one)? thanks [code] <?php function sql_quote($value) { if(get_magic_quotes_gpc()) $value = stripslashes($value); return  mysql_real_escape_string($value); } ?> [/code]
  3. well then there is no point in addslashes when im entering the data into the database? as it will already have slashes? thanks ricky
  4. im having problems with my forms. every time i enter the input eg. "o'really" it will return as "o\'really" i have setup my so that it shouldnt happen..here is my file...can anyone help? .htaccess [code] php_value magic_quotes_sybase off php_value magic_quotes_gpc off php_value magic_quotes_runtime off [/code]
  5. ok getting it to replace a string in a var works....but include the current form and changing a label doesnt seem to work... content: <label for"name">Name:</label> [code] $uri = $_SERVER['REQUEST_URI'];     ob_start(); require_once $document_root . $uri; $contents = ob_get_contents(); ob_end_clean(); $regex  = "|<label for=\"name\">(.+?)</label>|"; $replace = "<label for=\"name\" class=\"error\">$1</label>"; $contents = preg_replace($regex, $replace, $contents); return $contents; [/code]
  6. thanks ive used what you have given me and changed it a bit...but i doesnt seem to work can you have a look please? [code] <?php $contents = "<label for=\"test\">hello</label><input type=\"text\">"; $regex  = "|<label for=\"test\">(.+?)</label>|"; $replace = "<label for=\"test\" class=\"error\">$1</label>"; $contents = preg_replace($regex, $replace, $contents); return $contents; ?> [/code]
  7. this is a function which is apart of my form validation script...basically i want to replace a selected <label.... and change the class (class="error")..i think i have the script sorted....just the regular expression if someone could please help? the text inbetween the <label></label> tags in undecided and i want to copy that value into the relaced script....hope that explains what i need that destramic [code]     public function mark_label($input_name)     { $filename = $_SERVER['SCRIPT_NAME'];     ob_start(); require_once $document_root . $filename; $contents = ob_get_contents(); ob_end_clean();         $contents = str_replace("<label for=\"$input_name\">(.*)</label>", "<label for=\"$input_name\" class=\"\"></label>", $contents); return $contents;     } [/code]
  8. that hasnt made it work either... the problem is displaying this: [code] document.getElementById('toggle_checkboxes').innerHTML = "<a href=\"#\" onclick=\"toggle_checkboxes(this);\">Unselect all</a>" [/code] it wont display Unselect all
  9. could get it to work..could you help please? http://rafb.net/paste/results/VIRRly58.html thanks destramic
  10. my script seems to be working but when you click on select all the conent will dispear of some reason? can this be easily explained please? see here: http://rafb.net/paste/results/t2lvb839.html thanks destramic
  11. using mysql_real_escape_string you wouldnt need to use the function addslashes to the value aswell? (so on what instants would you use this addslashes?) and when mysql_real_escape_string is used to insert data would you use stripslashes while selecting data from the database? thank destramic
  12. here: http://rafb.net/paste/results/nRrdOh42.html
  13. well when you click on the text it wont start/run  the javascript
  14. thank you fenway for your advice...ive done that now.. script works fine..but script cannot be activated by text? view here: http://localhost/test.html
  15. thank you for your replywildteen88 i thought there might of been a easier way...but this is what ive done so far..doesnt work...dont think the regual expression is right...can you help? [code] $file  = $document_root . "/core/configuration.php"; // Check if file exists if (file_exists($file)) { // Open configuration file $handle  = fopen($file, "w+"); $contents =ob_get_contents(); $replace  = preg_match("define(/\"WEBSITE_URI\", \"[^\.\/]\"/);", $var, $contents); $write    = fputs ($handle, $string); // Close opened file fclose($handle); } else { echo "Unable to configuration file.<br />\n"; } [/code]
  16. my idea is to open configuration.php in replace.php and redefine the value of $WEBSITE_URI ans save it? is this possible? thank destramic configuration.php [code] // Website URI define("WEBSITE_URI", "www.domain.co.uk"); [/code] [code] ... [/code]
  17. im unable to get this to work with check boxes [code] function toggle_checkboxes(the_form) { for (var i = 0; i <the_form.length; i++) { if (the_form[i].type == 'checkbox') { the_form[i].checked = checkbox_status; } } if (checkbox_status) { checkbox_status = false; } else { checkbox_status = true; } } <span onclick="toggle_checkboxes(this.form);">Check/Uncheck all</span> [/code]
  18. the code below will work for strings and arrays...but doesnt seem to work for $_POST and $_GET etc...anyone figure out why ? [code] <?php function strip_slashes($value) { // Check if Magic Quotes is enabled if (get_magic_quotes_gpc()) { // Check if string exists if (is_string($value)) { return stripslashes($value); } elseif (is_array($value)) { return array_map('strip_slashes', $value); } } } ?> [/code]
  19. yes...could get it to work
  20. ok no worries ive got it to work now...can anyone help me on how i would do a onclick with just text alone?
  21. i think stripslashes should be done before data is added to the database...now we've got the function to work....how do i get it work on input boxes before going to mysql database... as ive said if i type: This\'s an string\'s on submit in the input field it will show: This\\\'s an string\\\'s
  22. im not sure on what you want to do but to use inside a function do something like this [code] <?php function vars(); {     echo $_GET['var'];     echo $_GET['id']; } // display function echo vars(); ?> [/code]
  23. <?php echo $id; ?> using php at the opening tag is good practice...sorry
×
×
  • 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.