Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    URGENT - unexpected $end drivin me nuts !

    HI guys

    bbewlow is my code..
    i have a unexpected $end error so i know im missing a closing tag or something daft somewhere but i cannot find it..

    been looking at this code for 3 hours now ..
    please help guys

    many thanks !


    PHP Code:
    <?php 
    include('config.php');
    mysql_select_db($dbn);
    if(isset(
    $_GET['keyword'])){
    $search=$_GET['keyword'];
    } else {
    $search '%';
    }

    // Pagination & DB Query ( INDEX PAGE )
    $limit '15';
     
    mysql_select_db($dbn$dbc);
     
    $page $_GET['page'];
     
    $cquery "SELECT * FROM phones WHERE `man` LIKE '$search' OR `product` LIKE '$search'";
     
    $cdoresult mysql_query($cquery$dbc);
     
    $cresult mysql_fetch_assoc($cdoresult);
     
    $totalrows mysql_num_rows($cdoresult);
     if(empty(
    $page)){    // Checks if the $page variable is empty (not set)
             
    $page 1;      // If it is empty, we're on page 1
         
    }
     
     
        
    $limitvalue $page $limit - ($limit);
         
    // Ex: (2 * 25) - 25 = 25 <- data starts at 25
     
    mysql_select_db($dbn$dbc);
     
    $prodquery mysql_query("SELECT * FROM phones WHERE `man` LIKE '$search' OR `product` LIKE '$search' LIMIT $limitvalue, $limit",$dbc);
     
    //echo $query;
     
    $prodresult mysql_fetch_assoc($prodquery);
    // End Pagination ( INDEX PAGE )
     
    ?>
     
    <!doctype html>
    <head>
    <meta name="description" content="Popular Phones is a mobile phone comparison site where business users and consumers can compare phones by make, model, 
    tariff and network"</> 
    <meta name="keywords" content="popular phones,popular phone, popular mobiles, popular mobile phones, compare business phones,business phone contracts"</>
    <title><?php echo $titlepre;?>Compare popular mobile phones across all tariffs and all networks</title>
    <base href="http://www.popularphones.co.uk">
    <link rel="stylesheet" type="text/css" href="style.css" />
    </head>
    <body>
    <div id="fb-root"></div>
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <div class="wrap">
        <div class="headerbox">
            <div class="logobox">
    <a href="http://www.popularphones.co.uk"><img src="logo.jpg" width="190px" height="30px" border="0" title="popular phones .co.uk compares mobile phones for 
    business users and consumers"></a> 
            </div>
            
            <div class="timedatebox"><?php echo date('l jS M Y')."<br />".date('g:ia');?></div>
        </div>

    <!-- Body Div -->
    <div class="bodywrap">
            <div class="newstopblock">
                <div class="newstopblocktext"><b>News : </b> Site Launch Date - November 5th 2012 !</div>
            </div>
            
                   <div class="newsletterbox">
                   <b>Newsletter</b><br/>
            Join the newsletter and stay updated on new phones, deals and special offers from the networks.
        <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST"><input type="textfield" name="email" id="email" value="Email"><input type="submit" 
        value="Subscribe" class="formbutton"><br/> 
        * You will be sent a link to click to confirm your newsletter subscription
        <?php if(isset($_POST['email'])){
        echo 
    "<br/><br/><b>Thank You - Check Inbox</b>";
        }
    ?>
    </div>
                 


            <div class="leftmenublock">
           <span class="leftmenulinks">&nbsp;&nbsp;<a href="http://www.popularphones.co.uk" class="leftmenulinks"><b>Home</b></a></span><br/><br/>
        <span class="leftmenuheader">Browse By Brand</span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=Apple" class="leftmenulinks">Apple iPhone</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=alcatel" class="leftmenulinks">Alcatel</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=blackberry" class="leftmenulinks">Blackberry</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=doro" class="leftmenulinks">Doro</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=htc" class="leftmenulinks">HTC</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=jcb" class="leftmenulinks">JCB</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=lg" class="leftmenulinks">LG</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=motorola" class="leftmenulinks">Motorola</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=nokia" class="leftmenulinks">Nokia</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=samsung" class="leftmenulinks">Samsung</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?keyword=sony" class="leftmenulinks">Sony</a></span><br/><br/>
        <span class="leftmenuheader">Browse By Network</span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?network=o2" class="leftmenulinks">O2</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?network=orange" class="leftmenulinks">Orange</a></span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?network=tmobile" class="leftmenulinks">T-Mobile</a></span><br/>    
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="search.php?network=vodafone" class="leftmenulinks">Vodafone</a></span><br/><br/>
            <span class="leftmenuheader">Business User ?</span><br/>
        <span class="leftmenulinks">&nbsp;&nbsp;<a href="#" class="leftmenulinks">Business Contracts</a></span><br/><br/><br/><a 
    href="http://www.awin1.com/cread.php?s=344590&v=3235&q=162516&r=70207"><img src="http://www.awin1.com/cshow.php?s=344590&v=3235&q=162516&r=70207" 
    border="0"></a> 
    <br/><br/><br/><br/>
    <a href="https://twitter.com/popularphones" class="twitter-follow-button" data-show-count="false" data-show-screen-name="true" data-lang="en">Follow 
    @PopularPhones</a> 
    <script>!function(d,s,id){var 
    js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> <br/><br/> 
    <div class="fb-like" data-href="http://www.popularphones.co.uk" data-send="false" data-width="150" data-show-faces="false" data-font="verdana"></div>
            </div>
    <div class="searchbox"><form action="<?php echo $_SERVER['PHP_SELF'];?>" method="GET">Search :</b> <input type="textfield" id="keyword" value="Enter 
    keywords" class="searchboxtxtfield" name="keyword"> <input type="submit" value="Search !"class="formbutton"><input type="hidden" id="page" value="1" 
    name="page"></form></div> 

                   <div class="toptextbox">
                   <?php echo $indextext;?>
                   </div>
                <div class="h1">Top 15 Phones Of The Week !</div>

            <div class="maincontentbox">
                
    <?php
                
    if($i !=3){
                do {
                
    ?>
    <?php
    // STR REPLACE ( PHONE & MODEL )
    $man str_replace(' ','+',$prodresult[man]);
    $model str_replace(' ','+',$prodresult[product]);    
    ?>


    <?php 
    if(!$cresult){ echo "Sorry, No Results Found"; } else {?>        <div class="indexphonedisplaybox">
    <span class="indexphoneheadertext"><a href="<?php echo $prodresult['deeplink'];?>" class="indexphonelinktext"><?php echo $prodresult['man'];?> <?php 
    echo $prodresult['product'];?></a></span><br/><span class="indextarifftext"><?php echo "<b>Tariff : </b>".$prodresult['tariff'];?><br/><b>Phone From :</b> 
    <?php echo $prodresult['price'];?></span><img src="<?php echo $prodresult['image'];?>" width="150px" height="150px" title="<?php echo $prodresult['man'];?> 
    <?php echo $prodresult['product'];?>"><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo $prodresult['deeplink'];?>
    class="indexphonelinktext">Click Here</a></div> 
                <?php 
    //PROPER PHONE URL <a href="phone.php?man=<?php echo $man;?>&model=<?php echo $model;?>&pid=<?php echo $prodresult[pid];?>
    }
    $i++;
                }while($prodresult = mysql_fetch_assoc($prodquery));
    }
    ?>     

            </div> <!--<div class="paginationblock"><?php 
        $numofpages 
    $totalrows 20;
     
        for(
    $j 1$j <= $numofpages$j++){
             if(
    $j == $page){
                 echo 
    "<a href=\"$_SERVER[PHP_SELF]?keyword=$search&page=$j\"
     class=\"paginationlink\"><u><b><font color=\"#FF0080\">$j</font></b></u></a> - "
    ;
             }else{
              echo 
    "<a href=\"$_SERVER[PHP_SELF]?keyword=$search&page=$j\"
     class=\"paginationlink\">$j</a> - "
    ;
             }
     
        }
              if((
    $totalrows 20) != 0){
             if(
    $j == $page){
                 echo(
    $j." ");
             }else{
              echo 
    "<a href=\"$_SERVER[PHP_SELF]?keyword=$search&page=$j\"
     class=\"paginationlink\">$j</a> - "
    ;
             }
         }
          
    ?></div>-->
    </div>        



    <!-- footer block -->
        <div class="copyblock copytext">&copy; Copyright <a href="http://www.popularphones.co.uk" class="copytext">Popular Phones</a> .co.uk <?php echo 
    date('Y');?></div> 
        <div class="footerblock">Test</div>
    </div>

    </body>

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,358
    Thanks
    61
    Thanked 530 Times in 517 Posts
    This isn't good for a start:
    PHP Code:
    //PROPER PHONE URL <a href="phone.php?man=<?php echo $man;?>&model=<?php echo $model;?>&pid=<?php echo $prodresult[pid];?>
    }
    $i++;
                }while($prodresult = mysql_fetch_assoc($prodquery));
    }
    ?>
    You've closed a php tag and then continue to try and run php.

    Thats all I found with a quick use of CTRL F in Notepad++ with the language set to php so that it highlights everything.

    Take a look at the link in my signature about this error. You'll see why notepad++ is a good bit of kit.

    You also need to consider keeping your php and html seperate. Run your php at the top and then print your variables into the html.
    Last edited by tangoforce; 10-30-2012 at 11:17 PM.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • Users who have thanked tangoforce for this post:

    littlechris (11-02-2012)

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,358
    Thanks
    61
    Thanked 530 Times in 517 Posts
    Quote Originally Posted by tangoforce View Post
    This isn't good for a start:
    Take a look at the link in my signature about this error.
    I've had to trim my signature of all its useful links and as you've not replied I'm not sure if you had chance to read it or not.

    Here is the link:
    TIP: Coding styles and $end errors
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #4
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts
    tango you are a life saver .. dunno why it did that .. the commenmt tag should have done the qwhole line .. but for some reason the code was going onto new line

    oh well sorted now thanks tango


  •  

    Posting Permissions

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