...

View Full Version : URGENT - unexpected $end drivin me nuts !



littlechris
10-30-2012, 10:02 PM
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
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>

tangoforce
10-31-2012, 12:14 AM
This isn't good for a start:


//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.

tangoforce
10-31-2012, 06:38 PM
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 (http://www.codingforums.com/showthread.php?p=1088720#post1088720)

littlechris
11-02-2012, 11:03 AM
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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum