Jump to content


New Members
  • Posts

  • Joined

  • Last visited


About Picabrillo

  • Birthday 09/14/1982

Profile Information

  • Gender
  • Location

Picabrillo's Achievements


Newbie (1/5)



  1. Thanks guys, that was really helpful. One more thing - Other than obviously typing less, are there general performance benefits for using shorthand character classes? From the impression I'm getting, the gains are small until you start dealing with more complex patterns (validating e-mail addresses or URIs maybe). Again, I would guess its as much to do with whether it's confusing to read or not.
  2. I would be interested to know why it seems confusing - to me it looks fine, but then again I should be getting into the practice of making it understandable to others. What would've you done differently effigy? As for A-z range, I see what you mean. Thanks for ASCII link, that was much better than some i've been to. I assume that A-Za-z would work better?
  3. Thanks effigy. Replaced '/[^A-z0-9 -\']/ ' with '/[^A-z0-9-\'\s]/' and its working fine now.
  4. <?php $val = "Normal (and bold) text!!"; $newval = preg_replace('/[^A-z0-9 -\']/', '', $val) echo $newval; // Outputs "Normal and bold text!!" ?> Why is it doing this? Have I missed something? It should only be allowing what I've asked for in the pattern - I don't see any exclamation marks being allowed. Thanks in advance
  5. I feel like such a donut! I've found the source of the problem. Unfortunately it was completely unrelated to anything I posted, so even the best person wouldn't have worked it out. What I posted was only a segment of a bigger program, but I'd ruled out any possibility that the problem was anywhere else. How wrong I was!! Sorry about that. The fact it worked for you Sasa made me think it was probably elsewhere, so thank you. I shall now go and enroll myself back into Primary school!!
  6. Hi, I can't see what's wrong with this. I've been looking at it for a long time, so maybe a fresh perspective might help. I created the multi-dimensional array like so: [code] <?php $array = array(); $array['options']['option1'] = array('id'); $array['options']['option2'] = 'name'; $array['options']['option3'] = 'age'; $array['options']['option4'] = 'address'; ?> [/code] But when later in the script I tested to see if option1 exists with isset($array['options']['option1']) it failed. I checked $array with print_r and it looked like this: [code] Array ( [0] => id ) Array ( [options] => Array   (   [option2] => name   [option3] => age   [option4] => address   ) ) [/code] All the other options are fine, I can test them with isset and they come back true. Can anyone give me any idea why option1 isn't a part of the options array even when I stated it? Thanks in advance people!
  7. You could try: [code] <?php $result = mysql_query("SELECT name FROM products"); $bg='#eeeeee';  // First row background color while($r=mysql_fetch_array($result); {       $bg = ($bg == '#eeeeee') ? '#ffffff' : '#eeeeee';  // Shorthand if statement (if $bg equals #eeeeee, add #ffffff to $bg, else add #eeeeee) ?> <tr style="background-color:<?php echo $bg; ?>"> Data for the row... </tr> <?php } ?> [/code] That'll alternate your background colours between 2 different colours, but not more than that. One way of doing more than 2 could be to store the colours in an array and access them that way. Like this: [code] <?php $result = mysql_query("SELECT name FROM products"); $bg = array('#dasdas', '#bbbbbb', '#cccccc', '#dddddd', '#eeeeee', '#ffffff');    // Range of background colours in order to display $index = 0;  // Which color in array to start at (0 being first one) while($r=mysql_fetch_array($result); {       $index = ($index < count($bg)) ? $index + 1 : 0; ?> <tr style="background-color:<?php echo $bg[$index]; ?>"> Data for the row... </tr> <?php } ?> [/code] Both of these should work. Sorry if it's not very clear, let me know if it not working.
  8. [font=Century Gothic][size=9pt] Hi, I've been developing a PHP4 MVC (Model-View-Controller) Framework, but I thought instead of using object classes I'd see whether it's plausible to make it with functions. I've managed to get a fair bit done, but I've recently hit a snag. The problem is that I'm using a lot of variables to manage the many routines that are required when it comes to creating individual pages. Because the pages use their own variables, there's a possibility that variables needed by the Framework could accidentally be overwritten - a problem I initially thought couldn't happen with object classes but proved false with PHP4. My initial thought was to create a routine that checks and shows an error if variable already exists, but that would make the site more insecure, as hackers could use this vulnerability to scan for words and overwrite content. Ideally I need to find a way to separate the variables used in the Framework from those generated by the individual pages. Any thoughts, simple or complex, would be welcome. Thanks in advance, and sorry for subjecting you to such a long message. If it makes no sense then please let me know. [/size][/font]
  • 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.