iframe doesn't work in PHP? [duplicate] - php

This question already has an answer here:
Echo inside an element attribute?
(1 answer)
Closed 10 years ago.
I have a php file which will show a list of images/products dynamically from the mysql database! This bit works just fine.
but I am trying to but the command in the iframe so I can create a slideshow affect using iframe!
but when I put the iframe around the command it doesn't work for some reason! it will open a 404 page on my 000web hosting server!!
here is my code:
<?php
include "config/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 10");
$i = 0;
// Establish the output variable
$dyn_table = '<table border="0" cellpadding="6">';
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
if ($i % 5 == 0) { // if $i is divisible by our target number (in this case "5")
$dyn_table .= '<tr><td><div style="position:relative" class="shadow tr" id="products_holder"><div style="position:absolute;left:-10px;top:-12px;">
<img src="images/best.png" width="97" height="94" />
</div><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></div></td>';
} else {
$dyn_table .= '<td><div style="position:relative" class="shadow tr" id="products_holder"><div style="position:absolute;left:-10px;top:-12px;">
<img src="images/best.png" width="97" height="94" />
</div><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></div></div></td>';
}
$i++;
}
$dyn_table .= '</tr></table>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<script src="scripts/modernizr-2.6.1.min.js"></script>
<title>site.com</title>
<style type="text/css">
</style>
</head>
<body>
<div align="center" id="wrapper">
<?php include_once("temps/header.php"); ?>
<div id="content">
<div id="apDiv1">
<h2>Top pros</h2></div>
<table width="100%" border="0" cellspacing="0" cellpadding="17">
<tr>
<td width="2%" height="20"> </td>
<td width="98%" height="20"><p><?php echo $dyn_table; ?></p>
</tr>
</table>
<table align="center" style=" table-layout:fixed; background-image:url(images/secondSection.png);" height="82" width="100%" border="0" cellspacing="10" cellpadding="10">
<tr>
<td width="2%" height="31"> </td>
<td style="vertical-align:top" align="center" width="28%"><div id="apDiv555" class="top_btns">
<h6 class="shadow"> More Products</h6>
</div></td>
<td style="vertical-align:top" align="center" width="70%"><div id="apDiv55" class="top_btns">
<h6><span class="shadow"> Search By Clothing | Search By Retailers</span></h6>
</div></td>
</tr>
</table>
<table style="background-image: url(images/tbl_bg.png); background-repeat: repeat-x;" height="350px" width="100%" border="0" cellspacing="12" cellpadding="0">
<tr>
<td width="3%"></td>
<td width="97%"><iframe src="<?php echo $dyn_table; ?>" height="250" width="100%" ></iframe></td>
</tr>
</table>
</table>
<table height="100" width="100%" border="0" cellspacing="17" cellpadding="17">
<tr>
<td> </td>
</tr>
</table>
</div>
</div>
<?php include_once ("temps/footer.php"); ?>
</body>
</html>
any help would be grately appreciated as I am almost done with this project.
Th

Just loose the iFrame and echo the $dyn_table inside the table you already have?

Your are not aware of what an iframe means, maybe :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<script src="scripts/modernizr-2.6.1.min.js"></script>
<title>site.com</title>
<style type="text/css">
</style>
</head>
<body>
<div align="center" id="wrapper">
<?php include_once("temps/header.php"); ?>
<div id="content">
<div id="apDiv1">
<h2>Top pros</h2></div>
<table width="100%" border="0" cellspacing="0" cellpadding="17">
<tr>
<td width="2%" height="20"> </td>
<td width="98%" height="20"><p><?php echo $dyn_table; ?></p>
</tr>
</table>
<table align="center" style=" table-layout:fixed; background-image:url(images/secondSection.png);" height="82" width="100%" border="0" cellspacing="10" cellpadding="10">
<tr>
<td width="2%" height="31"> </td>
<td style="vertical-align:top" align="center" width="28%"><div id="apDiv555" class="top_btns">
<h6 class="shadow"> More Products</h6>
</div></td>
<td style="vertical-align:top" align="center" width="70%"><div id="apDiv55" class="top_btns">
<h6><span class="shadow"> Search By Clothing | Search By Retailers</span></h6>
</div></td>
</tr>
</table>
<table style="background-image: url(images/tbl_bg.png); background-repeat: repeat-x;" height="350px" width="100%" border="0" cellspacing="12" cellpadding="0">
<tr>
<td width="3%"></td>
<td width="97%"><iframe src="my_iframe.php" height="250" width="100%" ></iframe></td>
</tr>
</table>
</table>
<table height="100" width="100%" border="0" cellspacing="17" cellpadding="17">
<tr>
<td> </td>
</tr>
</table>
</div>
</div>
<?php include_once ("temps/footer.php"); ?>
</body>
</html>
// Context on the my_iframe.php
<?php
include "config/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 10");
$i = 0;
// Establish the output variable
$dyn_table = '<table border="0" cellpadding="6">';
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
if ($i % 5 == 0) { // if $i is divisible by our target number (in this case "5")
$dyn_table .= '<tr><td><div style="position:relative" class="shadow tr" id="products_holder"><div style="position:absolute;left:-10px;top:-12px;">
<img src="images/best.png" width="97" height="94" />
</div><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></div></td>';
} else {
$dyn_table .= '<td><div style="position:relative" class="shadow tr" id="products_holder"><div style="position:absolute;left:-10px;top:-12px;">
<img src="images/best.png" width="97" height="94" />
</div><img style=" margin:5px; border:#ccc 1px solid" src="inventory_images/' . $id . '.jpg" width="150" height="160"/></div></div></td>';
}
$i++;
}
$dyn_table .= '</tr></table>';
echo $dyn_table;
?>
An iframe it's a totally different page, so you should use 2 pages....just like a propose, one for the html and one for the iframe....i hope it helps.
PS: I change the a href ;)
Saludos ;)

Related

How to insert Google Ads in left and right sidebar?

I want on my site to insert Google Ads on left and right sidebar, but I don't know how to create sidebars.
This is code from my header.php code that i have currently:
<?php
include "config.php";
?>
<html>
<head><meta name="adtictac-site-verification"
content="1qvt6zbzk026xfomo6gxbxxhjk9t96obv58gpcv3n9ver69s0"><meta
name="clckd" content="273a893ce34e0acd4ba2655313b5f902" />
<title><?php echo $sitename; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#2C60A9" leftmargin="1" topmargin="0" marginwidth="0"
marginheight="0">
<table width="777" border="2" bgcolor="#ffffff" align="center"
cellpadding="0" cellspacing="0" class="border">
<tr>
<td><img src="images/header.jpg" width="777" height="210" alt=""></td>
</tr>
<tr>
<td background="images/bg.jpg"><table width="100%" border="0"
cellspacing="0" cellpadding="0">
<tr>
<td width="30%"><img src="images/links.jpg" width="231" height="17"
alt=""></td>
<td width="7%"><A href="index.php"><img src="images/home.jpg" width="54"
height="17" alt="" border="0"></a></td>
<td width="11%"><A href="join.php"><img src="images/register.jpg"
width="83" height="17" alt="" border="0"></a></td>
<td width="7%"><A href="faq.php"><img src="images/faq.jpg" width="54"
height="17" alt="" border="0"></a></td>
<td width="12%"><A href="contactus.php"><img src="images/contact-us.jpg"
width="98" height="17" alt="" border="0"></a></td>
<td width="12%"><A href="advertise.php"><img src="images/advertise.jpg"
width="92" height="17" alt="" border="0"></a></td>
<td width="21%"><A href="login.php"><img src="images/login.jpg"
width="49" height="17" alt="" border="0"></a></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td class="bodytext"> </td>
<td> </td>
</tr>
<tr>
<td width="7%"> </td>
<td width="91%" class="bodytext"><p align="justify">
<?php
include "config.php";
$rs=mysql_query("select ID,BannerURL from bannersads where remaining>0 and
approved=1 and adtype=1 order by rand() limit 0,1");
while($arr=mysql_fetch_array($rs)) {
echo "<br><center><a href=$siteurl/tr.php?id=$arr[0] target=_blank><img
src=$arr[1] width=468 height=60 border=0></a><br></center><br>";
$rsu=mysql_query("update bannersads set remaining=remaining-1 where
ID=$arr[0]");
}
?>
So can someone share some tips how to create sidebars where need to create placed like shown in image? I tryed inserting this:
<div class="google">
// Google Code here
</div>
and this CSS:
.google {
margin-left:-250px;
}
but looks like broke my content in my homepage.
.google {
left: 250px;
}
Also create a container and give it width in px, not %.
Let me hope that will solve your problem.

PHP not passing SOME session variables to another script

I'm going nuts to try to understand why the script below (let's call it script1 is passing session variable $_SESSION['emptystcode'] to bulkstOLD.php but not the other two: $_SESSION['dlstrest'] and $_SESSION['dllist']. I have session_start(); on the first command line of the called script.
All this script1 does is to $_GET the Restaurant and List names and display a form where the user can fill in a CODE field and submit it.
To makes things worse, I've created another script (a simplified version of this caller script) which just set the session variables and calls the same bulkstOLD.php and it works ok. I wonder if this has something to do with the $_GET. Any help would be much appreciated.. Thanks!!
Here is the code:
<?php
session_start();
include ('logged.php');
require_once ('functions.php');
$acisversion = $_SESSION['acisversion'];
reset_all();
$cyear = date(Y);
$cmonth = date(M);
$cday = date(d);
$configs = include('config.php');
$_SESSION["module"] = 'st';
$_SESSION['favstlists_ref'] = 0;
$strest = $dlstrest = $_GET['dlstrest'];
$favstlist = $dllist = $_GET['dllist'];
$restname = 'restname_'.$strest;
$stlistrest = $configs[$restname];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>ACIS - Edit Lists</title>
<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="stmenu.js"></script>
<style type="text/css">
#import url(acis.css);
</style>
<script type="text/javascript" src="js.js"></script>
</head>
<body>
<div id="content">
<?php
$_SESSION['stcodesub'] = $stcodesub = $stcode = ($_POST["stcodein"]);
dbfile_init() ;
$_SESSION['stcode'] = $stcode;
if(isset($_POST["editSave"]))
{
connect_db ();
if (!empty($stcode))
{
check_code_for_st_list();
$emptystcode = 0;
}
else
{
$emptystcode = 1;
}
$_SESSION['dlstrest'] = $dlstrest;
$_SESSION['dllist'] = $dllist;
$_SESSION['emptystcode'] = $emptystcode;
if ((!$emptystcode and $codestok) or $emptystcode)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=bulkstOLD.php">';
exit;
}
}
?>
<table width="100%" border="0" align="center">
<tr>
<td width="223" align="left"></td>
<td width="111" align="right"></td>
</tr>
</table>
</style>
<form method="post" id="editLists" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<table width="739" border="0" align="center" cellspacing="0" bgcolor="#171717">
<tr>
<td colspan="3"
style="color:#00CC00;
text-align: left;
padding: 0;
background: #2e2e2e url(images/nav_bar.jpg) repeat-x;
font-size: 0.9em;
color: white;
height:16px;"><script type="text/javascript" src="mainmenu.js"></script></td>
</tr>
<tr>
<td width="502"><h2 style="color:red;"> Atualizar Listas Favoritas de Pratos</h2></style></td>
<td width="231" colspan="2" align="right"><?php echo $configs[footer];?></td>
</tr>
<tr>
<td colspan="3" align="right" ><table width="100%" border="0" align="center">
<tr>
<td align="center">Restaurante:</td>
<td width="84" align="center" valign="bottom">Adicionar Código</td>
<td width="350" align="center">Lista a ser atualizada:</td>
<td width="150" align="left" valign="bottom"><span class="error"><?php echo $favErr;?></span></td>
</tr>
<tr>
<td width="135" align="center"><b><?php echo $stlistrest; ?></b></td>
<td align="center">
<?php
echo $stcodeline;
?>
</td>
<td align="center"><b><?php echo $dllist; ?></b></td>
<td align="right"><input type="submit" name="editSave" style="background-color: #009900; color: #FFFFFF;" value="Submeter" /></td>
</tr>
</table></td>
</tr>
</table>
</form>
<?php
$_SESSION["module"] = 'st';
?>
</div>
</body>
</html>
The only possible explanation for your problem is that you might have not written <?php session_start();?> in the very beginning, before any HTML tags(even doctype). Write it on top of every relevant php document.
Look if all your files are saved as UTF-8 without BOM, not just UTF-8.
This BOM dissables sessions.
And look if all your files are called as they are in the same subdomain.
www.domain.com/file1.php,
ww2.domain.com/file2.php,
domain.com/file3.php
... with diferent subdomains should not work.

date format is not seperated when fetching from database

i have a table named as item_request and it has twofields named as projectmanager and createddate which has the Timestamp format as 2012-09-11 17:46:25.
Now i want to call these two fields in another form which count the user entry between 2 different dates.and the date field is fetched from the timestamp.with this form i m sending the value through datetime picker having the format 10-12-2012 but the value in databse is in different format and the value i m sending is in diffferent format.how is it possible plzzz help me guys.
Here is the code for my form:
<?php
include("config.php");
ob_start();
error_reporting(0);
if(!isset($_SESSION[username]))
header("location: index.php");
if(isset($_POST[submit]))
{
$projectmanager=mysql_real_escape_string($_POST['projectmanager']);
$date=mysql_real_escape_string($_POST['date']);
$dateexp = explode("-",$date);
$date = mysql_real_escape_string($dateexp[0]."/".$dateexp[1]."/".$dateexp[2]);
$date1=mysql_real_escape_string($_POST['date1']);
$dateexp1 = explode("-",$date1);
$date1 = mysql_real_escape_string($dateexp1[0]."/".$dateexp1[1]."/".$dateexp1[2]);
echo $queryuser= "select * from item_request where projectmanager=$projectmanager AND (requireddate>=$date AND requireddate<=$date1)";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Project Managers Registrarion</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<script language="javascript" type="text/javascript" src="js/datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com
</script>
</head>
<body>
<div class="container">
<div class="header"><img src="images/cherry-new.jpg" width="79" height="93" />
<!-- end .header --></div>
<?php include("rightMenu.php");?>
<div class="content">
<h1>PR Count</h1>
<div style="padding:10px 0px; text-align:center; color:#990000;">
</div>
<form action="" method="post" name="loginform">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>Project Managers</td>
<td><select name="projectmanager" style="width:145px;" id="projectmanager" onChange="showUser(this.options[this.selectedIndex].id)">
<option value="">Select</option>
<?php $queryuser= "select * from projectmanagers";
$fetuser1user = mysql_query($queryuser);
while($fetuser = mysql_fetch_array($fetuser1user)){
?>
<option id="<?php echo $fetuser['id']?>" value="<?php echo $fetuser['id']?>"><?php echo $fetuser['projectmanager']?></option>
<?php }
?>
</select></td>
</tr>
<tr>
<td>Date From</td>
<td>
<input id="date" type="text" size="20" name="date" /><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></td>
</tr>
<tr>
<td>Date To</td>
<td>
<input id="date1" type="text" size="20" name="date1"><img src="images/cal.gif" width="16" height="16" border="0" alt="Pick a date"></td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="submit" id="submit" value="Submit" onClick="return formvalidate();"/>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
<table width="100%" border="1"><tr>
<td width="18%" valign="middle" class="tableheading">PI.No.</td>
<td width="18%" valign="middle" class="tableheading">Project Manager</td>
<td width="18%" valign="middle" class="tableheading">Date Created</td>
<td width="15%" valign="middle" class="tableheading">Action</td>
</tr>
<?php
// to print the records
$select = "select * from item_request";
$query1 = mysql_query($select);
while($value = mysql_fetch_array($query1)){ ?>
<tr>
<td class="tabletext"><?php echo $value[id];?></td>
<td class="tabletext"><?php echo $value[projectmanager];?></td>
<td class="tabletext"><?php echo $value[datefrom];?></td>
<td class="tabletext"><img src="images/edit.png" width="25" height="25" border="0" title="Edit" />
<img src="images/deleteBtn.png" width="25" height="25" border="0" title="Edit" /></td>
</tr><?php }?>
</table>
</form>
<!-- end .content --></div>
<?php include("footer.php");?>
<!-- end .container --></div>
</body>
</html>
Replace this function call...
javascript:NewCal('date','ddmmyyyy');
with this one...
javascript:NewCal('date','ddmmyyyy',true,24);
Hope it helps.

parse error syntax error unexpected end of file in closed [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Can anyone find what is wrong with this code? i have Parse error: syntax error, unexpected end of file in C:\Program Files\EasyPHP-12.1\www\index.php on line 229
wondering if you can help me with this i'm so confused...
<?php include("./ayarlar.php");
if(isset($_GET['uygulama']) && $_GET['uygulama']=="cikis"){
$_SESSION['uyeKontrol']="";
$_SESSION['uyeTanimlama']="";
$_SESSION['uyeAdi']="";
header( 'Location: ./' );
}
?>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<script id="jquery.core" src="uygulamalar/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="uygulamalar/menu.js"></script>
<link href="tasarim/icon.png" rel="shortcut icon">
<title><?=$sitebaslik?></title>
<style type="text/css">
ul.listemiz{width:985px;list-style:none;float:left; padding:10px 0px 0px 23px;}
ul.listemiz li{width: 220px; height:211px; float: left; background:url(tasarim/list.png);padding:6px 18px 0px 0px;}
</style>
<style type="text/css">
ul.gorsel{width:1100px;list-style:none;float:left; margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;}
ul.gorsel li{width: 230px; height:143px; float: left; background:url(tasarim/tm.png);padding:6px 12px 0px 0px;}
</style>
<link rel="stylesheet" href="Standard/css/global.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js"></script>
<script src="Standard/js/slides.min.jquery.js"></script>
<script>
$(function(){
$('#slides').slides({
preload: true,
preloadImage: 'Standard/img/loading.gif',
play: 5000,
pause: 2500,
hoverPause: true
});
});
</script>
</head>
<body style="background-attachment: scroll; background-color:#E6E6E6">
<div class="temel">
<?php include("./site01.php");?>
<div id="sayfaicerigi"><div align="center"><br />
<table border="0" width="980" height="310" cellspacing="0" cellpadding="0">
<tr>
<td width="302" valign="top" align="left">
<?php if(isset($_SESSION['uyeKontrol']) && $_SESSION['uyeKontrol']!=""){?>
<table border="0" width="295" cellspacing="0" cellpadding="0" height="103" background="img/<?=$menu102?>.png">
<tr>
<td valign="top" align="center"></td>
</tr>
<tr>
<td valign="center" align="center" height="40">
<a href="hesabim">
<img border="0" src="img/<?=$menu108?>.png" width="120" height="32"></a>
<img border="0" src="img/<?=$menu109?>.png" width="120" height="32"></td>
</tr>
<tr>
<td valign="top" align="center" height="33">
<font face="Tahoma" color="#FFFFFF" style="font-size: 11pt">Hoş geldin: <?=$_SESSION['uyeAdi']?>
</font>
</td>
</tr>
</table>
<p><img border="0" src="img/EMLK.png" width="295" height="103"></p>
<?}else{?>
<table border="0" width="295" cellspacing="0" cellpadding="0" height="103" background="img/<?=$menu102?>.png">
<tr>
<td valign="top" align="center"></td>
</tr>
<tr>
<td valign="center" align="center" height="40">
<a href="kurumsal-giris">
<img border="0" src="img/<?=$menu104?>.png" width="120" height="32"></a>
<img border="0" src="img/<?=$menu103?>.png" width="120" height="32"></td>
</tr>
<tr>
<td valign="top" align="center" height="33">
<a href="uye">
<img border="0" src="img/uyecik.png" width="244" height="23"></a></td>
</tr>
</table>
<p><img border="0" src="img/EMLK.png" width="295" height="103"></p>
<?php }?>
</td><td width="13"></td>
<td width="665" valign="top" align="left">
<div style="position: absolute; width: 100px; height: 100px; z-index: 501" id="katman2">
<img src="Standard/img/new-ribbon.png" width="112" height="112" alt="New Ribbon" id="ribbon">
<div id="slides">
<div class="slides_container">
<?php
$mansetler = mysql_query("SELECT * FROM emlak order by id desc LIMIT 0,7");
while($manset = mysql_fetch_array($mansetler))
{
$mansetlerCO = mysql_query("SELECT * FROM resimler where emlak='".$manset['id']."'");
if($mansetCO = mysql_fetch_array($mansetlerCO))
{
}
?>
<a href="<?=$manset['id']?>_<?=duzgundur(StrToLower($manset['emlak']))?>.html" title="" >
<div style="position: absolute; width: 595px; height: 60px; top:220px; z-index: 102; background:#C0C0C0; color:#fff; overflow:hidden; z-index:200; opacity:.8; filter:alpha(opacity=80)" id="katman3" ><br> <b><font color="#000000" face="Tahoma" style="font-size: 12pt"><?=substr($manset['emlak'],0,60)?>.. - Fiyat: <?=$manset['fiyat']?> TL</font></b></div>
<img src="<?=$mansetCO['resim']?>" width="600" height="270" alt=""></a>
<?php }?>
</div>
<img src="Standard/img/arrow-prev.png" width="24" height="43" alt="Arrow Prev">
<img src="Standard/img/arrow-next.png" width="24" height="43" alt="Arrow Next">
</div>
<img src="Standard/img/example-frame.png" width="739" height="341" alt="Example Frame" id="frame">
</div>
</td>
</tr>
</table></div>
<table border="0" width="980" height="33" style="border-bottom:1px solid #dcdbdb;">
<tr>
<td valign="center" align="left" width="35">
<img border="0" src="tasarim/icon.png" width="24" height="24"></td>
<td valign="center" align="left" width="293">
<?=$menu3?></td>
<td valign="center" align="left" width="638">
<p align="right"><?=$menu100?> </td>
</tr>
</table>
<table border="0" width="980" height="131" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left" width="980">
<ul class="gorsel">
<?php
$rastgeleler = mysql_query("SELECT * FROM emlak WHERE durum=2 and onay=1 order by id desc LIMIT 8");
while($rastgele = mysql_fetch_array($rastgeleler))
{
?><li>
<table border="0" width="238" height="113" cellspacing="0" cellpadding="0">
<tr>
<td width="14"> </td>
<td width="115">
<a href="<?=$rastgele['id']?>_<?=duzgundur(StrToLower($rastgele['emlak']))?>.html">
<?php
$resimsecici = mysql_query("SELECT * FROM resimler where emlak='".$rastgele['id']."'");
if($resimci = mysql_fetch_array($resimsecici))
{
?><img border="0" src="goruntule?img=<?=$resimci['resim']?>&w=110&h=91"><?}?></a></td>
<td width="109"><font face="Tahoma" size="2"><?=$menu88?> :<?php if($rastgele['durum']==1){?><?=$menu19?><?}else{?><?=$menu20?><?php }?><br>
<?=$menu18?>: <?=$rastgele['fiyat']?> TL<br>
<?=$rastgele['ilce']?>/<?=substr($rastgele['il'],0,3)?>.<br>
<br>
<a href="<?=$rastgele['id']?>_<?=duzgundur(StrToLower($rastgele['emlak']))?>.html">
<img border="0" src="tasarim/<?=$menu97?>.png" width="84" height="18"></a></font></td>
</tr>
</table>
</li> <?}?>
</ul></td>
</tr>
</table>
<table border="0" width="980" height="33" style="border-bottom:1px solid #dcdbdb;">
<tr>
<td valign="center" align="left" width="35">
<img border="0" src="tasarim/icon.png" width="24" height="24"></td>
<td valign="center" align="left" width="272">
<?=$menu2?></td>
<td valign="center" align="left" width="659">
<p align="right"><?=$menu100?> </td>
</tr>
</table>
<table border="0" width="980" height="131" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" align="left" width="980">
<ul class="gorsel">
<?php
$rastgeleler = mysql_query("SELECT * FROM emlak WHERE durum=1 and onay=1 order by id desc LIMIT 4");
while($rastgele = mysql_fetch_array($rastgeleler))
{
?><li>
<table border="0" width="238" height="113" cellspacing="0" cellpadding="0">
<tr>
<td width="14"> </td>
<td width="115">
<a href="<?=$rastgele['id']?>_<?=duzgundur(StrToLower($rastgele['emlak']))?>.html">
<?php
$resimsecicim = mysql_query("SELECT * FROM resimler where emlak='".$rastgele['id']."'");
if($resimcim = mysql_fetch_array($resimsecicim))
{
?><img border="0" src="goruntule?img=<?=$resimcim['resim']?>&w=110&h=91"><?}?></a></td>
<td width="109"><font face="Tahoma" size="2"><?=$menu88?> :<?php if($rastgele['durum']==1){?><?=$menu19?><?}else{?><?=$menu20?><?php }?><br>
<?=$menu18?>: <?=$rastgele['fiyat']?> TL<br>
<?=$rastgele['ilce']?>/<?=substr($rastgele['il'],0,3)?><br>
<br>
<a href="<?=$rastgele['id']?>_<?=duzgundur(StrToLower($rastgele['emlak']))?>.html">
<img border="0" src="tasarim/<?=$menu97?>.png" width="84" height="18"></a></font></td>
</tr>
</table>
</li> <?php }?>
</ul></td>
</tr>
</table>
</div>
<br>
<?php include("./site02.php");?><br><br>
</div>
</body>
</html>
<?php
$_SESSION['gidenemlak']="";
?>
I think the problem is this piece: }?> Which is located somewhere in the middle of the code.
You shouldn't put brackets directly close to the open/close php tag, but separate with space: } ?>
The error is caused because of lacking space between open/close php tag and brackets. You should avoied this:
{?> AND <?}else{?>
Instead, you should have it like this:
{ ?> AND <?php else{ ?>
You are missing some ending curly brackets in your script

Displaying product categories

I'm creating a simple website for a business to display their products. On the index page I display the 3 newest products. What I need to do now is have a category page people can go to to view products in a certain category. I tried adapting the code from my index page but the products aren't showing up on my category.php.
I have a product_list.php with the different categories, when one is selected I'm trying to load category.php with the products from the category that was selected.
What I have:
product_list.php
<?php
include "storescripts/connect_to_mysql.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
</style>
<meta name="Description" content="Lightweight aluminum boat docks, lifts, and accessories" />
<meta name="Keywords" content="Aluminum boat dock ladder lift water wheels" />
<script src="scripts/swfobject_modified.js" type="text/javascript"></script>
</head>
<title><?php echo $product_name; ?></title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen"/>
</style>
<body>
<div align="center" id="mainWrapper">
<?php include_once("template_header.php");?>
<table width="100%" border="0" cellspacing="0" cellpadding="15">
<tr>
<td valign="top" align="center"><table width="100%" border="1">
<tr>
<td align="center"><p>Aluminum Docks</p>
<p><img src="inventory_images/aluminum docks/PN99002-6_24x4_PKG_LG.jpg" width="100" height="64" alt="24X4" /></p></td> // There's a field in my DB called categories, and 'docks' is the value assigned to the products
<td align="center"><p>Floating Docks</p>
<p><img src="inventory_images/floating dock/100225279.jpg" width="100" height="60" alt="Floating Dock" /></p></td>
<td align="center"><p>Frame Docks</p>
<p><img src="inventory_images/frame dock/frameDock.jpg" width="100" height="64" alt="Frame Dock" /></p></td>
<td align="center"><p>Pipe Docks</p>
<p><img src="inventory_images/pipe dock/PN99002_16X4_SECTION_LG.jpg" width="100" height="64" alt="Pipe Dock" /></p></td>
</tr>
<tr>
<td align="center"><p>Boat Lifts</p>
<p><img src="inventory_images/boat lifts/GM1060_LG.jpg" width="100" height="64" alt="Boat Lift" /></p></td>
<td align="center"><p>Boat Lift Accessories</p>
<p><img src="inventory_images/boat lift acceessories/canopy_lg (1).png" width="100" height="64" alt="Boat Lift Accessory" /></p></td>
<td align="center"><p>Rollers & Caddies</p>
<p><img src="inventory_images/rollers and caddies/caddy270 (1).jpg" width="100" height="64" alt="Caddy" /></p></td>
<td align="center"><p>Accessories</p>
<p><img src="inventory_images/accessorries/2step_LG.png" width="100" height="64" alt="Accessory" /></p></td>
</tr>
</table>
</table>
<p> </p>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>
in category.php I'm trying to create a variable called $dynamicList with all the products that have "dock" as a category. But when I echo out $dynamicList nothing is rendered.
<?php
// Run a select query to get my letest 6 items
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
$category=$_GET['category'];
$sql = mysql_query("SELECT * FROM products WHERE category='$category' LIMIT 6");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="17%" valign="top"><img style="border:#666 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="100" height="64" border="1" /></td>
<td width="83%" valign="top">' . $product_name . '<br />
$' . $price . '<br />
View Product Details</td>
</tr>
</table>';
}
} else {
$dynamicList = "We have no products listed in our store yet";
}
mysql_close();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
</style>
<meta name="Description" content="Lightweight aluminum boat docks, lifts, and accessories" />
<meta name="Keywords" content="Aluminum boat dock ladder lift water wheels" />
<script src="scripts/swfobject_modified.js" type="text/javascript"></script>
</head>
<title><?php echo $category; ?></title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen"/>
</style>
<body>
<div align="center" id="mainWrapper">
<?php include_once("template_header.php");?>
<table width="100%">
<tr>
<td valign="top"><p><?php echo $dynamicList;?><br />
</p>
<p> </p>
<p> </p> <h2> </h2></td>
</tr>
</table>
<p> </p>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>
EDIT: $dynamicList is nested in a condition statement. Just write
$dynamicList = '';
before your query
What is the current output on the page? Are the # of rows returned in the query = 0?
You should also sanitize your $category input using mysql_real_escape_string()
WHERE category ='".mysql_real_escape_string($category)."' ...
You must sanitize first the strings using this function:
public static function real_escape($string)
{
if (null != $string) {
$string = (get_magic_quotes_gpc()) ? $string : addslashes($string);
return mysql_real_escape_string($string);
}
return $string;
}
Or better use third party script like phpDataMapper
$sql = mysql_query("SELECT * FROM products WHERE category='$category' LIMIT 6");
should be
$sql = mysql_query("SELECT * FROM products WHERE category='".$category."' LIMIT 6");
This is the only error I can discover for now

Categories