Jump to content

casbboy

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Posts posted by casbboy

  1. I have a table with rows of small bits of html code.

    I have already set it up to look for each row that has an image in the code like so

    <img src="http://www.site.com/file.jpg" width="80" height="90">

    I need to create a program with preg_match and preg_replace that will first find the image file's source and then remove the entire image tag.

    the image tags can be slightly different. some have the '/' at the end and some come with alt tags.

    How can I do this? I need to get the source then remove the whole thing entirely.

    Thanks
    Ryan
  2. Here is what I have:

    First, I set up two arrays to be used later (from a mysql query):

    [code=php:0]
    while($alinks = mysql_fetch_array($listlinks)) {
    $clinks[] = $alinks['link'];
    $cid[] = $alinks['article_id'];
    }
    [/code]

    Now I check to see if a new set of links matches any in the $clinks array:

    [code=php:0]
    $nc = 0;
    $pos = 0;
    foreach($info[items] as $in) {
    if(in_array($info[items][$nc][link], $clinks))  {
    $pos = strpos($info[items][$nc][link], $clinks);
    $abar = '<a href="/article/'. $cid[$pos] .'"><img src="/images/art/indexed.gif" border="0"></a>';
    } else {
    $abar = '<img src="/images/art/notindexed.gif">';
    }
    $nc = $nc + 1;
    }
    [/code]

    If the link already exists, I want the 'article_id' of the matched link to be placed in to the href.  Hence I have the $cid array with the $pos variable giving the position with $cid[$pos]. 

    Unfortunately, this isn't working as I had hoped, and only gives the same number for all the links that match.

    ANy suggestions?

    Thanks
    Ryan
  3. I have a mod-rewrite working that puts the title of an article into an html looking page like so.

    [a href=\"http://www.sample.com/name-of-file.html\" target=\"_blank\"]http://www.sample.com/name-of-file.html[/a]

    I want to make sure that characters not allowed in the URL don't make it in there.

    Is there a PHP function that removes everything that typically isn't allowed in an URL address?

    such as ( ) " ' html tags carrots and more?

    Thanks
    Ryan
  4. I have a php update like this:

    [code=php:0]
    $upsql = mysql_query("UPDATE comments SET comment2='$oldcomment', comment='$newcomment', edited='y', verified='$verified' WHERE user_id='$userid' AND edited='n' AND comment_id='$commentid'", $connection)
    or die(mysql_error());
    [/code]

    The problem is that $oldcomment features a ton of text that has both "this" type of quotation marks and 'this' type of quotation marks. I get a mysql error because of these quotation marks when trying to update the database.

    I have done a string replace to pull them out just for testing sake and the update works fine... so it is the existance of the quotation marks that are causing issues.

    i NEED these quotation marks to remain, but how can I do the update query and avoid the error?

    Thanks
    Ryan
×
×
  • 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.