Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Need Help with Capitalization & PHP

  1. #1
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default Need Help with Capitalization & PHP

    Ok so here is my code

    PHP Code:
    $myAd "Do you own a site about \"$q\"? "
    I want to use the ucwords function on $q but I cant get it to work.

    Can anyone help me please.
    Last edited by tgallagher26; 03-17-2009 at 01:45 PM.

  2. #2
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    PHP Code:
    $myAd 'Do you own a site about "' ucwords($q) . '"? '

  3. #3
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Yea I ha already tied that.

    look at the ad space below banner ad and you can see the results.

    http://kywordpro.com/txt/1/10/kansas%20city%20zoo.html

  4. #4
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    You have to put PHP tags around that.
    Code:
    <?php
    Code:
    ?>

  5. #5
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    I know I already have it PHP like this.

    PHP Code:
    <?php


    if(!file_exists('config.php')) header('Location: install.php');

    include 
    'config.php';
    include 
    'inc/database.php';
    include 
    'inc/functions.php';
    clearCache($options[$clear]);
    remUserAd();
    if(isset(
    $_GET['q']) && strlen(trim($_GET['q'])) > 1) {
        
    $q urlencode($_GET['q']);
        
    $flag true;
        if(!
    isBlackListed($q)) {
            
    $blackListed false;
            
    $array = array('txt''img''avi''news''mp3');
            
    $a strtolower($_GET['a']);
            if(!
    in_array($a$array)) $a 'txt';
            include 
    'inc/search.php';
        }
        else {
            
    $blackListed true;
        }
        
    $q urldecode($q);
    }
    $myAd "<font face=\"verdana\" size=\"2\"><table bgcolor=\"ffff88\" width=\"100%\"><tr>
    <td valign=\"top\">
    <a href=\"http://kywordpro.com/sponsor/index.php\"><b>Advertise Your Website with KyWordPRO!</a></b><br />
    Do you own a site about \"' . ucwords(
    $q) . '\"? Then put your text ad right here in front of 1000's of potential customers with our Targeted Keyword Ads for only $20.00 a year.<br /><span style=\"color: green;\">http://kywordpro.com/sponsor/index.php</span></td></tr></table> </font>";

    $txt=($_GET['a'] == 'txt' || !isset($_GET['a'])) ? " checked=\"checked\"" "";
    $img=($_GET['a'] == 'img') ? " checked=\"checked\"" "";
    $avi=($_GET['a'] == 'avi') ? " checked=\"checked\"" "";
    $news=($_GET['a'] == 'news') ? " checked=\"checked\"" "";
    $mp3=($_GET['a'] == 'mp3') ? " checked=\"checked\"" "";
    $footer=file_get_contents('http://kywordpro.com/footer.php');

    $mainpage='<div id="header"><br /><br /><br /><br /><div  id="main" style="width: 600px; margin: 100px auto;" valign="center" align="center">
    <center><br /><a href="http://kywordpro.com/index.php"><img src="http://kywordpro.com/img/logo.gif" border="0" alt="" style="margin-bottom: 20px;" /></a><br />
    <form action="http://kywordpro.com/redirect.php" method="get" class="style1">
    <p style="margin-top: 10px;">
    Web: <input type="radio"'
    $txt .' name="a" value="txt" /> | 
    Images: <input type="radio"'
    $img .' name="a" value="img" /> | 
    Video: <input type="radio"'
    $avi .' name="a" value="avi" /> | 
    News: <input type="radio"'
    $news .' name="a" value="news" /> | 
    Music: <input type="radio"'
    $mp3 .' name="a" value="mp3" /><br />
    </p>        
    <input type="text" name="q" size="55" value="'
    ucwords($q .'') .'" /><br />
    <input type="submit" value="KyWordPRO Search" />
    <input type=\'hidden\' name="num" value="10"></form>
    '
    $footer .'<br /></center></div><br /><br /><table align=center><tr><td id="main">
    <font face="verdana" size=1">Background Sponsered by 
    <a href="http://links.verotel.com/cgi-bin/showsite.verotel?vercode=19175:9804000000002269">3d-passion.com</a></font></td></tr></table></div>'
    ;
    ?>

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    $myAd = "<font face=\"verdana\" size=\"2\"><table bgcolor=\"ffff88\" width=\"100%\"><tr>
    <td valign=\"top\">
    <a href=\"http://kywordpro.com/sponsor/index.php\"><b>Advertise Your Website with KyWordPRO!</a></b><br />
    Do you own a site about \"' . ucwords($q) . '\"? Then put your text ad right here in front of 1000's of potential customers with our Targeted Keyword Ads for only $20.00 a year.<br /><span style=\"color: green;\">http://kywordpro.com/sponsor/index.php</span></td></tr></table> </font>";
    Code:
    $myAd = '<div class="advertisement"><p><a href="http://kywordpro.com/sponsor/index.php">Advertise Your Website with KyWordPRO!</a></p><p>Do you own a site about '. ucwords($q) .'?. Then put your text ad right here in front of 1000's of potential customers with our Targeted Keyword Ads for only $20.00 a year.</p></div>';
    then add this to your stylesheet
    Code:
    div.advertisement {
        font-family: Verdana sans-serif;
        width:100%;
        background-color: #ffff88;
    }

    I would also suggest that you validate your page, since I can see a number of really poor HTML.

    See www.w3c.org and www.howtocreate.co.uk for more information

  7. #7
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    PHP Code:
    <input type="text" name="q" size="55" value="'. ucwords($q .'') .'" /><br /> 
    Make the above look like Tim's example.

  8. #8
    Join Date
    Feb 2009
    Posts
    62
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    Boogyman this is the result

    Parse error: syntax error, unexpected T_STRING in /home/content/t/g/a/tgallagher26/html/index.php on line 27
    Last edited by tgallagher26; 03-16-2009 at 07:00 PM.

  9. #9
    Join Date
    Mar 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The problem is that you are not escaping from the php correctly. It should be sort of like this:

    PHP Code:
    <?php
    echo "<input type=\"text\" name=\"q\" size=\"55\" value=\"".ucwords($q)."\" />";
    ?>

  10. #10
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    It should be like this:

    PHP Code:
    <input type="text" name="q" size="55" value="<?php echo ucwords($q); ?>" />
    You should not be putting HTML inside PHP tags. Or as strings in variables. There are exceptions, but I don't see any in your code.

    This for example

    PHP Code:
    $myAd "<font face=\"verdana\" size=\"2\"><table bgcolor=\"ffff88\" width=\"100%\"><tr>
    <td valign=\"top\">
    <a href=\"http://kywordpro.com/sponsor/index.php\"><b>Advertise Your Website with KyWordPRO!</a></b><br />
    Do you own a site about \"' . ucwords(
    $q) . '\"? Then put your text ad right here in front of 1000's of potential customers with our Targeted Keyword Ads for only $20.00 a year.<br /><span style=\"color: green;\">http://kywordpro.com/sponsor/index.php</span></td></tr></table> </font>"
    is not good.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •