Jump to content

Mr Candu

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Mr Candu's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks very much that works perfectly - Time to buy myself a good reg ex tutorial book!
  2. Hi, The following preg_replace reg ex grabs all characters between the box tags: /\[box](.+?)\[\/box\]/ Eg: [box]Characters Grabed[/box] I'm am terrible with regular expressions and have failed in getting the code to grab all characters including line breaks and carriage returns. I think I should be using the \s character, but I can't figure out where to stick it? Any help is much appreciated! Thanks, Mat.
  3. Thanks for you help guys. Vineld's original suggestion works well for me, so thanks very much. I probably should have explained in more detail what i am ultimately trying to achieve: The code is part of a CMS system. The function will parse a text field from a db on output and replace all tags (of which their could be many) with the appropriate HTML <img src=whateverSrc /> tag. The create_image function will query the db to retrieve the image src for the given id. $text = preg_replace_callback('/\[img\=(.+?)\]/', create_function('$matches', 'return create_image($matches[1]);'), $text); I not sure if this is the most efficient way of doing things, but it is the only option the works out of suggestions posted. Cobins suggestion works only for 1 occurrence of an tag, though I'm rubbish at reg ex and maybe it could be adjusted there? $text = preg_replace('/\[img\=([0-9]+)\]/e', 'create_image("\1")', $text); Thanks for you help.
  4. Hi. My code uses preg_replace to extract an image id (16) from a text string (""). The id is then sent to another function and the image information is returned. Unfortunatley the id seems to be passed as some kind of text string that cannot be converted to an interger. As a test example for you to look at, the following code returns 16,0 when it should be returning 16,16 If you have any advice on why this is happening I would be very greatful ...... i'm slowly losing the will to live! Regards, Mat. <?php function create_image($imgid) { return $imgid.",".(int)$imgid; } $text = "[img=16]"; $text = preg_replace("/\[img\=(.+?)\]/",create_image('$1'),$text); echo $text."<br>"; ?>
  5. Hi, My xml document "visitors.xml" has the following layout: <?xml version="1.0" ?> <visitors> <visitor id="1"> <name>John Smith</name> <site>1</site> </visitor> <visitor id="2"> <name>Mrs Golubovic</name> <site>1</site> </visitor> </visitors> I would like to do the following 2 things with PHP5 preferably using DOM XML, though if xpath and/or simplexml is better suited that would be fine also. 1) Open the xml file and change the name of the visitor with an attribute id of 1, from John Smith to Jane Smith, then save the file. 2) Open the xml file an add a new visitor record with an attribute id of 3, name of Rob Jones and site of 1, then save the file. Any help and advice you might be able to give me would be great. Thanks in advance, Mat.
  6. Hello there. I am trying to get php to query an informix DB, but at the moment I am just running into the error message: "Warning: odbc_connect(): SQL error: [Informix][Informix ODBC Driver]Unable to load translation shared library (DLL)., SQL state IM009 in SQLConnect in C:\Inetpub\wwwroot\BusinessIntel\tvha_bi\incfiles\dbconnect.php on line 2 Connection Failed:" My current setup is as follows: IIS v5 PHP v4.4 Informix Client SDK v2.90 I have configured a System DNS in the ODBC Data source admin, and tested the connection in the admin, and it works fine. I have also tried querying the dbase from access 2003, which also works fine. So there seems to be a problem with php communicating with odbc informix drivers. I have not configured php for use with informix, but I was sure this wasn't the necessary if using php odbc querys rather than informix querys. The error message refers to a translation library, and I noticed there are options in the odbc setup for a translation library and option, but I am unsure as to what to enter there. Any help taking this problem forward would be a massive help, as I am well and truly stuck at the moment. Many Thanks, Matthew Cohen
×
×
  • 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.