Setting a variable

Discussion in 'PHP' started by bluewaves, Jul 22, 2010.

  1. #1
    I am just new to using variables, so be patient with me. I have set a variable on a content page in a php include script. It works fine.

    I set is like this:
    
    <?php
    	include ('header.php');
           $cat='german sheperds';
    	?>
    
    Code (markup):
    So I can use the variable $cat in an sql query successfully. I'd like to learn to use it in the script below that pulls in youtube videos. It gets the topic of the video from:

    render=rss&tags=beagle+dogs'

    What I want to know is how can I get the script to read tags=$cat

    ???? so it inserts german sheperds in the call?

    Thanks so much.
    <?php
    require_once '/home2/mysite/public_html/examples/carp/carp.php';
    CarpLoadPlugin('youtube.php');
    CarpLoadPlugin('youtube.php');
    CarpConf('iorder',',youtube');
    CarpConf('maxitems',3);
    $youtubeconf['width']=200;
    $youtubeconf['height']=175;
    $youtubeconf['language']='de';
    $youtubeconf['after']='<hr>';
    $youtubeconf['show-border']=1;
    $youtubeconf['show-related']=0;
    $youtubeconf['color-1']='000066';
    $youtubeconf['color-2']='006633';
    CarpConf('aiauthor','</i></b><br />');
    CarpConf('cborder','date');
    CarpConf('bilink','<b>');
    CarpConf('ailink','</b><br>'); 
    CarpConf('bcb','<h2>Beagle Dog Videos</h2><p><font size="2">');
    CarpConf('bidate','<i>YouTube Video Uploaded on:'); 
    CarpConf('aidate','</i><p>'); 
    CarpConf('acb','</font>');
    CarpConf('bca','<font size="1">');
    CarpConf('aca','</font>'); 
    CarpConf('aidesc','<p>');
    CarpConf('acb','<p>');
    CarpConf('maxidesc',400);
    
    
    
    // Add any desired configuration settings before CarpCacheShow
    // using "CarpConf" and other functions
    
    
    
    // surround the item link with a DIV
    CarpConf('bilink','<div style="background:#cccccc; width:200px; padding:2px; border:1px solid #333333;">');
    CarpConf('ailink','</div>');
    
    // get rid of the underline under the links
    CarpConf('ilinkstyle','text-decoration:none');
    
    // set the CSS classes of the channel and item links
    CarpConf('clinkclass','h2');
    CarpConf('ilinkclass','h2');
    
    // Display it
    
    CarpCacheShow('http://pipes.yahoo.com/pipes/pipe.run?_id=qLeMq8782xG2oyVwCB2yXQ&_render=rss&tags=beagle+dogs');
    echo '<p>';
    CarpConf('iorder','link,desc');
    CarpConfAdd('descriptiontags','|img|a|/a');
    
    
    ?>
    Code (markup):
     
    bluewaves, Jul 22, 2010 IP
  2. atxsurf

    atxsurf Peon

    Messages:
    2,394
    Likes Received:
    21
    Best Answers:
    1
    Trophy Points:
    0
    #2
    use: "render=rss&tags=$cat"
    (double not single quotes)
    or: 'render=rss&tags='.$cat
     
    atxsurf, Jul 22, 2010 IP
  3. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    <?php
        // Your category here
        $cat = 'german sheperds';
    
        require_once '/home2/mysite/public_html/examples/carp/carp.php';
        CarpLoadPlugin('youtube.php');
        CarpLoadPlugin('youtube.php');
        CarpConf('iorder',',youtube');
        CarpConf('maxitems',3);
        $youtubeconf['width']=200;
        $youtubeconf['height']=175;
        $youtubeconf['language']='de';
        $youtubeconf['after']='<hr>';
        $youtubeconf['show-border']=1;
        $youtubeconf['show-related']=0;
        $youtubeconf['color-1']='000066';
        $youtubeconf['color-2']='006633';
        CarpConf('aiauthor','</i></b><br />');
        CarpConf('cborder','date');
        CarpConf('bilink','<b>');
        CarpConf('ailink','</b><br>'); 
        CarpConf('bcb','<h2>'.htmlentities(ucwords($cat)).' Videos</h2><p><font size="2">');
        CarpConf('bidate','<i>YouTube Video Uploaded on:'); 
        CarpConf('aidate','</i><p>'); 
        CarpConf('acb','</font>');
        CarpConf('bca','<font size="1">');
        CarpConf('aca','</font>'); 
        CarpConf('aidesc','<p>');
        CarpConf('acb','<p>');
        CarpConf('maxidesc',400);
    
        // Add any desired configuration settings before CarpCacheShow
        // using "CarpConf" and other functions
    
        // surround the item link with a DIV
        CarpConf('bilink','<div style="background:#cccccc; width:200px; padding:2px; border:1px solid #333333;">');
        CarpConf('ailink','</div>');
    
        // get rid of the underline under the links
        CarpConf('ilinkstyle','text-decoration:none');
    
        // set the CSS classes of the channel and item links
        CarpConf('clinkclass','h2');
        CarpConf('ilinkclass','h2');
    
        // Display it
        CarpCacheShow('http://pipes.yahoo.com/pipes/pipe.run?_id=qLeMq8782xG2oyVwCB2yXQ&_render=rss&tags='.urlencode($cat));
        echo '<p>';
        CarpConf('iorder','link,desc');
        CarpConfAdd('descriptiontags','|img|a|/a');
    ?>
    
    PHP:
     
    Deacalion, Jul 22, 2010 IP