Jump to content

ianco

Members
  • Posts

    81
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ianco's Achievements

Member

Member (2/5)

0

Reputation

  1. I get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's add' ORDER BY pageid DESC LIMIT 20' at line 1
  2. Hi all. I've been looking at this for several hours not with no progress. I feel it should be simple but I'm getting nowhere. Here's the problem. I want to provide a list of links where from a table called pages. When $title = "Dave's comment"; for example I get nothing back. If there is no apostrophe in the field it works fine. It's as though I can't find the field. $query = mysql_query("SELECT * FROM pages WHERE title = '$title' ORDER BY pageid DESC LIMIT 20"); while($row = mysql_fetch_assoc($query)) { $title = $row['title']; echo $title; } any ways around this? Thanks Ian
  3. I'm not sure JOINS will work because the cell could contain e.g. "2,5,19,21" so i can have $range = "2,5,19,21"; but I want to change that into an array $arr = array($range);
  4. Hi all, I want to create an array from the output of a table. In the table cell I have some numbers where for each number I would like to relate it to a value in another table. However using the code below I get Array ( [0] => "26","27","28","29","30","31" ) from the print_r($arr); meaning that $range ins't being treated as an array, and hence, the second query only gives one value. $showIng = mysql_query("SELECT * FROM recipe WHERE name = '$dish'") or die(mysql_error()); $rowShowIng = mysql_fetch_assoc($showIng); $range = $rowShowIng['keyno']; $arr = array($range); print_r($arr); foreach ($arr as &$value) { $getIng = mysql_query("SELECT * FROM keywords WHERE keyid = '$value'") or die(mysql_error()); $rowGetIng = mysql_fetch_assoc($getIng); echo $rowGetIng['ingredient']; } So, I want to know how I can create the array from $range Thanks
  5. joe92, thanks I'll look into preg_replace_callback
  6. xyph, you're not wrong, I previously had $pagecontent = preg_replace('#<h2>([^<]+)</h2>#i', "==$1==", $pagecontent); and you wouldn't line break a heading
  7. thanks guys Xyph, your solution works but it can't handle line breaking tags i.e. <br> or <br />, it makes some of the tags disappear. Can you give me more info on the parser joe92 i need the nested tags so i don't think your way will work
  8. Hi, I'm trying to turn '<div class="infobox"><div class="infoboxtitle">this is a title</div><div class="infoboxtext">example text</div></div> into [infobox][infoboxtitle]this is a title[/infoboxtitle][infoboxtext]example text[/infoboxtext][/infobox] so, using preg_replace i have: $pagecontent = preg_replace('#<div class="infoboxtitle">([^<]+)</div>#i', "[infoboxtitle]$1[\/infoboxtitle]", $pagecontent); $pagecontent = preg_replace('#<div class="infoboxtext">([^<]+)</div>#i', "[infoboxtext]$1[\/infoboxtext]", $pagecontent); $pagecontent = preg_replace('#<div class="infobox">([^<]+)</div>#i', "[infobox]$1[\/infobox]", $pagecontent); But it's not giving me anything back. Any idea where I'm going wrong? Thanks Ian
  9. Hi, Sorry for the delay in getting back. Using the same code I just changed the function to function gallery($username){ echo "this is my ".$username; } the variable $username is available on all my pages but all I was seeing is: this is my Anyway, I'll have a play around and mark this thread as solved. Thanks Ian
  10. Hi again, Although I haven't got an actual use for this yet I've been thinking. From the code that was helpfully provided, you can't put variables into the function, i.e., gallery($username). Is there a solution to this or should it actually work and I'm just being a spanner <?php $s='text, e.g. [!gallery!], that is contained in blog post'; $p=',\[!([^!]+)!\],'; $s=preg_replace_callback($p, function ($match) {return $match[1]();}, // calls gallery() $s); function gallery() {return '//function GALLERY was here//';} echo $s; ?>
  11. Got it! it wasn't working because i had the function gallery() in another function. Thanks very much for the help!!!! Ian
  12. Hey thanks for the replies. PLayful, the first example in your first reply works great and gives me the variable. I guess what I originally envisioned was using the variable in an include e.g., include($gallery.'php'), then have a function in that file. I think your second methods sound like a better idea. The second reply example 2 seems to kill the rest of my script but is a good idea and works on its own so I will have a play around and let you know
  13. $somevariable would just be what is contained between [! and !] preg_replace may not be the most appropriate function
  14. Hi, I want to be able to replace text, e.g. [!gallery!], that is contained in blog post and have the word 'gallery' as a variable $gallery so i can use it to fetch files/call a function. This is what I have so far: $rowblog[Content] = preg_replace("/\[\!(.*?)\!\]/","$somevariable", $rowblog[Content]); as far as I know the variable isn't being created. Any idea of a solution? Thanks Ian
×
×
  • 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.