Jump to content

maexus

Members
  • Posts

    191
  • Joined

  • Last visited

    Never

Everything posted by maexus

  1. I know someone knows this. Please take 5 minutes and help.
  2. [code] $string = preg_replace('#\[\[(.+?)\|(.+?)\]\]#is', '<a href="$1" title="$2">$2</a>', $string); [/code] [[http://google.com/|google.com]] will output: <a href="http://google.com/" title="google.com">google.com</a> In order to use other bbcode or images inplace for the link I need this: [code] $string = preg_replace('#\[\[(.+?)\|(.+?)\|(.+?)\]\]#is', '<a href="$1" title="$3">$2</a>', $string); [/code] But how can I write it so it won't need both $2 and $3 to spit out the url. Like if $2 and $3 isn't there, it would just use $1 for as a replacement? Or do I have to write 2 regex patterns?
  3. Oh, how I loath RegEx. If anyone can point me in the right direction? Maybe I should just buy a book on it. I can't find a single site online that I can read and just start spitting out regular expressions any time I need one, which is alot.
  4. I have to goto work today so no time for coding but I really appreciate the help.
  5. [!--quoteo(post=375624:date=May 20 2006, 09:03 PM:name=Veto)--][div class=\'quotetop\']QUOTE(Veto @ May 20 2006, 09:03 PM) [snapback]375624[/snapback][/div][div class=\'quotemain\'][!--quotec--] thanks for the reply dave. a few questions regarding ur post above : 1. is there anyway for me not to input the ip addresses manually? like getting it automatically on the first time the user visits the page without him knowing any of this (asking for him to fill in n stuff)? 2. is this all possible using php alone? if it is, can u point me to the correct path on making this script? like which syntax to use, any webites that teach me how to do it aor something like that due to the fact this is my FIRST attempt on php :( thanks! [/quote] 1: $_SERVER['REMOTE_ADDR']
  6. I don't have my mind set on SimpleXML so if you have a method to do what I need to do. [img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] Please share. It would be very much appreciated. [!--quoteo(post=375525:date=May 20 2006, 11:21 AM:name=yonta)--][div class=\'quotetop\']QUOTE(yonta @ May 20 2006, 11:21 AM) [snapback]375525[/snapback][/div][div class=\'quotemain\'][!--quotec--] I also have the same question. Is it possible to write in a xml file at the given element i want like mysql, changing only that value or do i have to load the whole xml into a variable and rewrite it whole again with the changes i want? Thanx [/quote] I believe you can change an XML entry easily enough. All you have to do, if you use SimpleXML is to specify which entry you want to change by either using [#] or using XQuery. I believe you could use XQuery for that, which is very similar to SQL queries in syntax.
  7. I am writing a databaseless shoutbox, which the txt version is done. I'm converting it to XML so I can add features such as search, delete, edit, ect... I can read XML using SimpleXML just fine, no problems. The problem I run into is writing xml. I want to be able to write to the XML in very much the same way I would using INSERT in SQL. Append the file using the new data but add it on at the end of the file but before the end root element. Any help would be great. :-D
  8. Pretty easy, just echo the db field for the url into a html hyperlink. [code] <?php echo <a href="'.$row['userurl'].'">$row['userurl']</a>; ?> [/code] Something like that? Of course you will need to adapt it to your code.
  9. You could store the data in a session or just create a preview page with a form to submit the data after it's been previewed. Using javascript isn't really the best way because a user may disable js or the browser they are using may not support js.
  10. This used to work before but when I rewrote it, it doesn't.. My userlevels are stored as constants [code] //User Levels define('ADMIN',        4); define('MOD',        3); define('USER',        2); define('GUEST',        1); define('BANNED',    0); [/code] My registration script stores these userlevel titles as a string to access later on during login and page security. Before I could say.. [code] $results = mysql_query('some query'); $row = mysql_fetch_assoc($results); echo $row['userlevel']; [/code] That should output like USER which is a constant so it really outputs 2 into the script. That's what it used to do but now it outputs USER, which is no good. I have to end up using [code] $user['level'] = constant($row['userlevel']); [/code] Now this works but it's annoying because I never had to do this before... My question is, what is the best way to store a constant name in a DB then spit the value back out, not as a string, but as something the PHP parsing will automaticly parse as a constant? Sorry if this is confusing.
  11. You can't take away the open option, that is browser level stuff >_> Controlled by the user through the browser.
  12. Well, I tried a simple test. I created a new test directory. In that dir, I created a dir called lib. In lib I have the master include file, as noted before. test.php and config.php. test.inc.php [code] <?php require_once 'config.php'; function test(){     echo BASE_URL; } ?> [/code] config.php [code] <?php define('BASE_URL', 'http://localhost/test'); ?> [/code] and finally index.php [code] <?php require_once 'lib/master.php'; test(); ?> [/code] I get BASE_URL outputted and not [a href=\"http://localhost/test\" target=\"_blank\"]http://localhost/test[/a]. Now, if I add require_once 'lib/config.php'; to index.php along with the master file, it outputs the constant value. ~_~ This completely defeats the purpose of using the master include. I think the problem may be with how I setup require_once. I don't know. I've been trying to figure this out for a while now.
  13. For my blog source, I have alot of custom functions that I need to include. It started to become a real pain so I've started to use one master include file that pulls in all the include files I need all at once. This seems like it would work, but having issues. Here is my master include file: [code] <?php #List all the files you wish to include... $includes = array(     'strings.inc.php',     'test.inc.php' ); require_once 'config.php'; foreach($includes as $include){     require_once $include; } [/code] Now.. my config.php file is filled with constants. This is a fairly meaty file and really esentinal for the operation of the code. I call it first. Then I call all the includes in the array after that. Now, this setup works when I have like 3-4 include files and like 15 functions total. The more functions I have and the more files to include... I keep getting "Function 'test' is undefined" when it IS defined. If I include the file directly, it works just fine. Also, I call the config file before anything else, yet I can use the constants in there in other included files. The only solution I can see is to include the config.php for each include file. I tried that, and it still doesn't access the value for a constant. Can someone help me please.
×
×
  • 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.