Jump to content

dcro2

Members
  • Posts

    489
  • Joined

  • Last visited

    Never

Posts posted by dcro2

  1. Your mysql_query is probably failing, so add a check for failure:

     

    // Find highest answer number.
    $sql="SELECT MAX(a_id) AS Maxa_id FROM reply WHERE question_id='$id'";
    $result=mysql_query($sql) or die("MySQL error: ".mysql_error());
    $rows=mysql_fetch_array($result);

  2. Try using the method I posted. Like this for your DisplayPage function:

     

    <?php
    function DisplayPage($page_id, $page_type) {  //the two variables here are used to select the right info from database, and which template to use
            ob_start();
            include_once($_SERVER['DOCUMENT_ROOT'].'/templates/home-template.htm');
            $output = preg_replace("/~~PAGECONTENT~~/",$row['page_content'],ob_get_clean(),1);
            echo $output;
    ?>
    

     

    Worked perfectly for me. Use [ php ] for php code btw. [ code ] doesn't color php code unless you wrap it in <?php ?>

  3. How do you expect it come out exactly? The way you have it set up right now you'll just have a ton of columns with one link inside each.

     

    <tr> is a row. <td> is a column. Each <tr> (row) of a table can have multiple <td> (column) inside, and of course you have to end the <tr> in order to get a new row.

     

  4. I *think* if you use output buffering you could somehow get this to work. For example, call ob_start() right before include()ing the html file. Then, call ob_get_clean() to get what the included file outputted and clean the buffer so it doesn't output to the browser.

     

    ob_start();
    include('somehtmlwithphpcode.html');
    $output = ob_get_clean();
    

     

    That'll let the file actually execute and $_GET stays the same.

  5. Put 'em into two arrays?

     

    //might have scope problems otherwise?
    $approvedurls = array();
    $unapprovedurls = array();
    
    foreach($vanity_url as $v){
    	if($v->approved){
    		$approvedurls[] = $v->url;
    	}
    	else {
    		$unapprovedurls[] = $v->url;
    	}
    }
    
    echo "Approved vanity urls:";
    foreach($approvedurls as $url) echo $url;
    echo "Unapproved vanity urls:";
    foreach($unapprovedurls as $url) echo $url;
    

     

    I'm still confused how you got that output without any newlines however.

  6. Is sendmail setup correctly? Is this on your own machine/server or is it on shared hosting? Php has to use a smtp server to send mail succesfully. Also, make sure you check your spam folder since these emails could come from a strange source (from hotmail's point of view).

     

    PS: you might want to take out your email from your post. Spambots and whatnot.

  7. My bad. Meant to post this as the second link: http://www.gidforums.com/t-1816.html. Good luck!

     

    Edit: sorry, that only matches links starting with http(s)://

     

    Here's something that might work with some modifications:

     

    	$t = " ".preg_replace( "/(([[:alnum:]]+:\/\/)|www\.)([^[:space:]]*)".
    	"([[:alnum:]#?\/&=])/i", "<a href=\"\\1\\3\\4\" target=\"_blank\">".
    	"\\1\\3\\4</a>", $t);
    

    From here: http://snipplr.com/view/29556/php-parse-url-mailto-and-also-twitters-usernames-and-arguments/

  8. No problem, just remember that my example was pretty simple and will fail on a lot of links that aren't written the same way. There's some more advanced regular expressions here for example. As for what you're asking for, I would probably convert all <a> tags into plain urls and then use something like this to convert them all back along with the unlinked ones.

  9. I think if you just do something like this it could work:

     

    $timetoadd = "10"; //from your text field
    $time = "1500"; //from database
    
    $newtime = date('Hi', strtotime($time." +".$timetoadd." minutes"));
    

     

    I couldn't get it to work with something like 00:10:00 for some reason, but this is the concept. You can do +10 minutes, hours, months, years, etc.

     

    Note: I used 'Hi', not 'hi' because lower-case h is 12-hour time, so you would get 0310.

  10. imagecreatefromjpeg() is looking for Rainbow-code-1_blck.jpg in the directory your php script is in. Include the whole path like you did with file_exists():

     

    $filename = "Rainbow-code-1_blck.jpg";
    if (file_exists(sfConfig::get('sf_upload_dir') . '/rainbowcode/images/profilepics/'.$filename))
    {
        echo "file found";
         $source = imagecreatefromjpeg(sfConfig::get('sf_upload_dir') . '/rainbowcode/images/profilepics/'.$filename);
    }
    

  11. Err.. sorry, I got confused. What I meant to say is it will only get the url from the first <a>. It will replace all occurrences. You could get all the urls like this:

     

    
    <?php
    
    $text = '<a href="http://theurl.com/">link</a>\n<a href="http://theurl2.com/">link2</a>';
    $replacement = 'the replacement here';
    
    //put the urls inside $urls if we find a match
    if(preg_match_all('/<a href="(.*?)">/i', $text, $matches)) {
    //$matches[1] contains all matches to the first subpattern
    $urls = $matches[1]
    }
    
    //replace all <a> tags with $replacement
    $text = preg_replace('/<a href=".*?">.*?<\/a>/i', $replacement, $text);
    
    ?>
    

  12. Something like this maybe:

     

    <?php
    
    $text = '<a href="http://theurl.com/">link</a>';
    $replacement = 'the replacement here';
    
    //put the url inside $url if we find a match
    if(preg_match('/<a href="(.*?)">/i', $text, $matches)) {
    $url = $matches[1];
    }
    
    //replace the whole <a> tag with $replacement
    $text = preg_replace('/<a href=".*?">.*?<\/a>/i', $replacement, $text);
    
    ?>
    

     

    It will only replace the first occurrence in your text.

  13. Well, you can't put WHERE clause in an INSERT, but I don't know what you're trying to do...

    [code]INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
        [INTO] tbl_name [(col_name,...)]
        VALUES ({expr | DEFAULT},...),(...),...
        [ ON DUPLICATE KEY UPDATE col_name=expr, ... ][/code]

    Are you trying to find which table has that value? If so, you should search for it beforehand.
×
×
  • 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.