How to compare the equality of two strings in php? - php

I want to check the equality of the "$v" and "$formats2". But it gives and error message
Warning: strcmp() expects parameter 2 to be string, array given in C:\xampp\htdocs\playit2\product.php on line 312
Here is my HTML code.
$jsqla = mysql_query("select * from products where id='$product_id'") or die(mysql_error());
$jfeta = mysql_fetch_assoc($jsqla);
$formats = explode(";", $jfeta['formats']);
$jsqla2 = mysql_query("select formats from request_list where id='$product_id'") or die(mysql_error());
$jfeta2 = mysql_fetch_assoc($jsqla2);
$formats2 = explode(";", $jfeta2['formats']);
<div class="">
<?php if($formats2 != "") { ?>
<?php foreach($formats as $v){ ?>
<label style="line-height: 1.25em;display: block;width: 100px;margin-right: 10px;float: left;">
<div id="format-id_<?php echo $v?>" <?php if (strcmp($v, $formats2) === 0) { ?> style="border: 1px solid;border-radius: 9px;text-align: center;padding-top: 10px;padding-bottom:10px;padding-left: 3px;padding-right: 3px;border-color: #cccccc;font-family: 'SSemibold'; font-size: 13px; color: #44b7da; background-color: #cccccc;" <?php } else { ?> style="border: 1px solid;border-radius: 9px;text-align: center;padding-top: 10px;padding-bottom:10px;padding-left: 3px;padding-right: 3px;border-color: #cccccc;font-family: 'SSemibold'; font-size: 13px; color: #44b7da;" <?php } ?>>
<input class="format_cheks" type="radio" value="<?php echo $v; ?>" name="abc" style="visibility:hidden;" id="<?php echo $v ?>" onClick="changeColour(this)"/>
<span style="margin:-17px auto auto 0px;display:block;"><?php echo $v; ?></span>
</div>
</label>
<?php } ?>
<?php } else { ?>
<?php foreach($formats as $v){ ?>
<label style="line-height: 1.25em;display: block;width: 100px;margin-right: 10px;float: left;">
<div id="format-id_<?php echo $v?>" style="border: 1px solid;border-radius: 9px;text-align: center;padding-top: 10px;padding-bottom:10px;padding-left: 3px;padding-right: 3px;border-color: #cccccc;font-family: 'SSemibold'; font-size: 13px; color: #44b7da;">
<input class="format_cheks" type="radio" value="<?php echo $v; ?>" name="abc" style="visibility:hidden;" id="<?php echo $v ?>" onClick="changeColour(this)"/>
<span style="margin:-17px auto auto 0px;display:block;"><?php echo $v; ?></span>
</div>
</label>
<?php } ?>
<?php } ?>
</div>

You mistyped implode as explode. The latter takes a string and produces an array. You likely want the opposite. UPD: Oh, you already have a string. Then simply use it as is:
- $formats2 = explode(";", $jfeta2['formats']);
+ $formats2 = $jfeta2['formats'];
Hope it helps.

You also use
if( $val1 === $val2){
//true part . this === strictly check
}

You should pass the key as after explode it will contain an array.
strcmp($v, $formats2[key])
explode()

Related

How to display 2 images per slide in carousel using php while loop?

I have a problem with displaying images in carousel. I want to display 2 images per carousel slide. I took images from database using while loop to create slides. The problem is that with my code it only displays one image per slide.
This is how it looks now:
Check the image
<?php
$brojacPoStrani = 0;
$sqlIzvestaji = mysqli_query($con, "SELECT operacije.nazivEng, izvestaji.operacija, izvestaji.ucinak, izvestaji.id FROM izvestaji INNER JOIN operacije ON izvestaji.operacijaId=operacije.id WHERE projekatId='$projekatId' AND datum='$datum'");
while ($row = mysqli_fetch_array($sqlIzvestaji)) {
$id = $row['id'];
$sqlSlike = mysqli_query($con, "SELECT img_name FROM slike WHERE izvestajId='$id' AND datum='$datum'");
$brojacDuplikata = false;
while ($row2 = mysqli_fetch_array($sqlSlike)) {
if ($brojacPoStrani % 2 == 0) {
?>
<div class="carousel-cell" style="background-image: url('img/izvestaji.jpg'); background-repeat: no-repeat; background-size: 100% 350px;">
<h1 style="color: #fff; text-align: left; padding-left: 15px; font-weight: bold;"><?php echo $row['nazivEng']; ?></h1>
<?php
if ($brojacDuplikata === false) {
$brojacDuplikata = true;
?>
<p style="text-align: left; padding-left: 45px; padding-top: 20px; padding-bottom: 10px;"><?php echo $row['operacija'] . " - " . $row['ucinak']; ?></p>
<?php
} else {
?>
<p style="text-align: left; padding-left: 45px; padding-top: 40px; padding-bottom: 10px;"></p>
<?php
}
?>
<div class="row">
<?php
if ($brojacPoStrani % 2 == 0) {
?>
<div class="col-lg-6">
<img src="../files/izvestaji/<?php echo $project; ?>/<?php echo $datum; ?>/<?php echo $row['nazivEng']; ?>/<?php echo $row2['img_name']; ?>" style="width: 350px; height: 350px; padding-left: 10px;" class="float-right" />
</div>
<?php
} else {
?>
<div class="col-lg-6">
<img src="../files/izvestaji/<?php echo $project; ?>/<?php echo $datum; ?>/<?php echo $row['nazivEng']; ?>/<?php echo $row2['img_name']; ?>" style="width: 350px; height: 350px; padding-right: 10px;" class="float-left" />
</div>
<?php
}
?>
</div>
<br />
</div>
<?php
}
$brojacPoStrani++;
}
$brojacPoStrani = 0;
}
As mentioned it looks like you should be able to use a single query rather than having nested queries - and to display 2 images per carousel slide you effectively want to select data from the current and next rows. One easy way to do that would be to assign the entire recordset to a variable and then process that array using a for loop. The following is a simplified, semi-pseudo code version that attempts to combine the sql queries and assign recordset to an array. It is not tested as such but it might? be of use.
$sql="select
o.naziveng,
i.operacija,
i.ucinak,
i.id,
s.img_name
from izvestaji i
inner join operacije o on i.operacijaid=o.id
inner join slike s on s.izvestajId=i.id
where projekatid='$projekatid' and datum='$datum'";
$res = mysqli_query( $con, $sql );
if( $res ){
$arr = mysqli_fetch_all( $res, MYSQLI_BOTH );
for( $i=0; $i < count( $arr ); $i+=2 ){
try{
$r1=array_key_exists( $i+0, $arr ) ? $arr[ $i+0 ] : false;
$r2=array_key_exists( $i+1, $arr ) ? $arr[ $i+1 ] : false;
/*
generate the HTML structure and add two images
*/
echo '<div class="carousel-cell">'; # simplified version
if( $r1 )echo 'row 1: '.$r1['img_name'];
if( $r2 )echo 'row 2: '.$r2['img_name'];
echo '</div>';
}catch( Exception $e ){
continue;
}
}
}

Getting the names of users with foreach

I want to recover the names returned by the query below (it's part of the code):
while ($info = $q->fetch(PDO::FETCH_OBJ)) {
foreach(array_chunk($info, 5) as $info){
echo ' <div class="user-block" style="display: inline-block;">
<h4>'.$info->name.'</h4>
</div> ';
}
}
But I get this:
Error: Warning: array_chunk() expects parameter 1 to be array, object
given And that error: Warning: Invalid argument supplied for foreach()
Two possiblities:
a) Try using PDO::FETCH_ASSOC instead of PDO::FETCH_OBJ. And change $info->name to $info['name']
b) You're only get 1 result from your query returned so it's not an array. Remove the foreach loop
I already used this:
<?php $listes_amis = liste_amis_commun_profil_clique(); ?>
<?php foreach(array_chunk($listes_amis, 5) as $liste_amis): ?>
<div>
<?php foreach($liste_amis as $liste_ami): ?>
<div class="user-block" style="display: inline-block;">
<a href="voir_profil.php?id=<?php echo $liste_ami->id;?>">
<img src="../members/<?php echo $liste_ami->id?>/avatar/<?php echo $liste_ami->avatar; ?> " style='margin: 3px; width: 150px; height: 150px;' class="img-circle" />
<h4 style="font-size: 20px; color: green; text-align: center; margin-top: -2px;" > <?php if(strlen($liste_ami->nom ."+".$liste_ami->prenom) > 15) echo substr($liste_ami->prenom,0,-10).'...'; else echo $liste_ami->prenom ." ".$liste_ami->nom; ?> </h4>
</a>
</div>
<?php endforeach ?>
</div>
<?php endforeach ?>
And it works well here

displaying csv data in four columns in php

I have complaint.csv file in which data is like below:
1,complaint of health
2,complaint of money
.
.
.
71,complaint of bill
I want to show above data in four columns in PHP such that each column will have equal numbers of rows.
I have tried below code in which I couldn't able to get success.
<?php
$fp = file('../complaint.csv', FILE_SKIP_EMPTY_LINES);
$total_rows = count($fp);
$count = $total_rows;
$first_col = ceil($count/ 4);
$count -= $first_col;
$second_col = ceil($count/ 3);
$count -= $second_col ;
$third_col = ceil($count/ 2);
$forth_col = $count - $third_col ;
while (!feof($fp)) {
$lines[] = fgetcsv($fp, 1024);
}
fclose($fp);
?>
<div class="added">
<div class="column-left">
<?php
for ($i = 0; $i < $first_col; $i++)
{
foreach ( $lines as $line):
?>
<label class="checkbox" for="<?php print 'checkbox'.$line[$i][0]; ?>" style="font-size:20px;">
<input type="checkbox" name="complaint" value="<?php print $line[$i][0]; ?>" id="<?php print 'checkbox'.$line[$i][0]; ?>" data-toggle="checkbox">
<?php print $line[$i][1]; ?>
</label>
<?php
endforeach;
}
?>
</div>
<div class="column-center">
<?php
$k = $i;
for ($j = 0; $j < $second_col; $j++)
{
foreach ( $lines as $line):
?>
<label class="checkbox" for="<?php print 'checkbox'.$line[$j][0]; ?>" style="font-size:20px;">
<input type="checkbox" name="complaint" value="<?php print $line[$j][0]; ?>" id="<?php print 'checkbox'.$line[$j][0]; ?>" data-toggle="checkbox">
<?php print $line[$j][1]; ?>
</label>
<?php
endforeach;
$k++;
}
?>
</div>
<div class="column-center-right">
<?php
$m = $k;
for ($l = 0; $l < $third_col; $l++)
{
foreach ( $lines as $line):
?>
<label class="checkbox" for="<?php print 'checkbox'.$line[$l][0]; ?>" style="font-size:20px;">
<input type="checkbox" name="complaint" value="<?php print $line[$l][0]; ?>" id="<?php print 'checkbox'.$line[$l][0]; ?>" data-toggle="checkbox">
<?php print $line[$l][1]; ?>
</label>
<?php
endforeach;
$m++;
}
?>
</div>
<div class="column-right">
<?php
$n = $k;
for ($p = 0; $p < $forth_col; $p++)
{
foreach ( $lines as $line):
?>
<label class="checkbox" for="<?php print 'checkbox'.$line[$p][0]; ?>" style="font-size:20px;">
<input type="checkbox" name="complaint" value="<?php print $line[$p][0]; ?>" id="<?php print 'checkbox'.$line[$p][0]; ?>" data-toggle="checkbox">
<?php print $line[$p][1]; ?>
</label>
<?php
endforeach;
$n++;
}
?>
<br/>
</div>
</div>
CSS
<style>
.column-left{ float: left; width: 25%; }
.column-right{ float: right; width:25%; }
.column-center{ float: left; width: 25%; }
.column-center-right{ float: left; width: 25%; }
div.added {
padding: 0px 0px 5px 0px;
font-size: 22px;
font-family: "freightbook";
color: #2a4753;
text-align: left;
}
</style>
I am getting Error like Notice: Uninitialized string offset. The affected lines are between foreach loop
Can anyone please tell me, what went wrong in above code or any other solution of it?
Here's a solution:
Variable number of columns
Unequal number of lines are filled from left to right
Formatting of HTML elements thru styles (CSS)
Input (complaint.csv)
1,complaint of health
2,complaint of money
3,complaint type 3
4,complaint type 4
5,complaint type 5
6,complaint type 6
7,complaint type 7
8,complaint type 8
9,complaint of bill
Code
<?php
// Setup ---------------------------------------------------------------
define('numcols',4); // set the number of columns here
$csv = array_map('str_getcsv', file('./complaint.csv'));
$numcsv = count($csv);
$linespercol = floor($numcsv / numcols);
$remainder = ($numcsv % numcols);
// Setup ---------------------------------------------------------------
// Page, part 1 --------------------------------------------------------
echo '<html
<head>
<style type="text/css">
BODY { font-family:tahoma,arial,helvetica,sans-serif; font-size:76%; }
.table { background-color: #e0e0e0; }
.break { break:both; border:0; with:1px; }
.column { border:0; float:left; padding:0.333em; }
</style>
</head>
<body>
';
// Page, part 1 --------------------------------------------------------
// The n-column table --------------------------------------------------
echo '<div class="table">'.PHP_EOL;
echo ' <div class="column">'.PHP_EOL;
$lines = 0;
$lpc = $linespercol;
if ($remainder>0) { $lpc++; $remainder--; }
foreach($csv as $item) {
$lines++;
if ($lines>$lpc) {
echo ' </div>' . PHP_EOL . '<div class="column">'.PHP_EOL;
$lines = 1;
$lpc = $linespercol;
if ($remainder>0) { $lpc++; $remainder--; }
}
echo ' <label class="checkbox" for="checkbox'.$item[0].'" style="font-size:20px;">
<input type="checkbox" name="complaint" value="'.$item[0].'" id="'.$item[0].'" data-toggle="checkbox">'
.$item[1].
'</label><br />';
}
echo ' </div>'.PHP_EOL;
echo '</div>'.PHP_EOL;
// The n-column table --------------------------------------------------
// Page, part 2 --------------------------------------------------------
echo '</body>
</html>
';
// Page, part 2 --------------------------------------------------------
?>
Result
Hope this will help you. By using the PHP inbuilt SPL classes.
<?php
$file = new SplFileObject("./FL_insurance_sample.csv", "r");
$file->setFlags(SplFileObject::READ_CSV);
$file->seek($file->getSize());
$linesTotal = $file->key();
$recordsInColumn = floor($linesTotal / 4);
$res = array();
foreach ($file as $line) :
$res[] = $line;
endforeach;
$finalRecord = array_chunk($res, $recordsInColumn);
$classNames = array('column-left','column-right','column-center','column-center-right');
foreach ($finalRecord as $key => $data) : ?>
<div class="<?php echo $classNames[$key]; ?>">
<?php foreach ($data as $key1 => $row) :
if ($row[0] !== null && $row[1] !== null):
?>
<label class="checkbox" for="<?php print 'checkbox' . $row[0]; ?>" style="font-size:20px;">
<input type="checkbox" name="complaint" value="<?php print $row[0]; ?>" id="<?php print 'checkbox' . $row[0]; ?>" data-toggle="checkbox">
<?php print $row[1]; ?>
</label>
<?php
endif;
endforeach; ?>
</div>
<?php endforeach;
?>

why products url is repeating in magento

I'm using Magento 1.7.0. I want to show latest ordered products on homepage sidebar. Almost everything is ready and working properly except its URL.
I don't know why products URL is repeating again and again. Products' images, it's name and price is showing correct only it's URL gets repeated for each product.
Each product have the same first product URL.
Here is the code
<style>
.productList { float:left; width:720px; }
.productList .product { background:#fff; border:1px solid #eedfa6; padding:3px; float:left; text-align:center; width: 182px; margin-bottom: 7px; height: 200px; }
.productList .product .cl { padding:0 0 0 0px; text-align:center;}
.productList .product .prodDetails {font-weight: bold;font-size: 12px; color: #2a2a28;text-align:center; padding:0 0 0 0px; }
.productList .product .prodDetails a{color: #d77932;}
.productList .product .prodDetails a:hover{color: #3d4d68 ;}
.productList .product .addCompare { text-align:center; clear:both; }
.productList .product .addWishlist {clear:both; text-align:center; }
}
</style>
<?php
$result = $this->getBestsellerProduct();
$itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 2 ;
//getting product model
$model = Mage::getModel('catalog/product');
$products_price = Mage::getStoreConfig('bestseller/general/products_price');
$review = Mage::getStoreConfig('bestseller/general/review');
?>
<div style="width:200px;float:right;">
<div class="sectionHead" style=""><h2><?php echo $this->getHeader(); ?></h2><div style="height: 25px;border-bottom: 2px solid #eedfa6 /*#DBDBDB;*/" class="hrline"></div></div>
<table border="0" cellpadding="0" cellspacing="0" class="productList" style="width:100px;">
<?php $i=0;
for($cnt = 0; $cnt<5; $cnt++){
$_product = $model->load($result[$cnt]); //getting product object for particular product id
?>
<tr>
<td class="product">
<div class="prodimage">
<!-- code added by Saurabh-->
<?php echo $_product->getProductUrl() ?>
<?php if ($_product->getExt_image_url()!=''){$srcImage=$_product->getExt_image_url();} else{$srcImage=$this->helper('catalog/image')->init($_product, 'small_image');} ?>
<!--saurabh code ended here-->
<a href="<?php echo $_product->getProductUrl() ; ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<img src="<?php echo $srcImage; ?>" width="150" height="145" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</a>
</div>
<div align="center">
<div class="prodDetails" align="center" style="width:175px;" >
<?php $_product_name= $_product->getName(); ?>
<?php $_short_product_name = substr($_product_name, 0, 40); ?>
<?php $_dot_product_name=$_short_product_name.'...' ; ?>
<?php echo $_dot_product_name ;?>
<?php if($review == 1)
{
$_product = Mage::getModel('catalog/product')->load($_product->getId());
echo $this->getReviewsSummaryHtml($_product, 'short');
}
if($products_price == 1)
{
$_product = Mage::getModel('catalog/product')->load($_product->getId());
echo $this->getPriceHtml($_product, true);
}
?>
</div>
<?php $addtocartval = $this->getAddToCart();
if($addtocartval == 1){
if($_product->isSaleable()): ?>
<button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php else: ?>
<span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>
<?php endif; }?>
</div>
<div class="cl">
<?php $wishlists = $this->getActive();
if($wishlists == 1){
if ($this->helper('wishlist')->isAllow()) : ?>
<?php echo $this->__('Add to Wishlist') ?>
<?php endif; }?>
</div>
<div class="cl">
<?php $addtocompare = $this->getAddToCompare();
if($addtocompare==1){
if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<?php echo $this->__('Add to Compare') ?>
<?php endif; }?>
</div>
</td>
</tr>
<?php
}
?>
</table>
</div>
First ,check $result[$cnt] is same for every time??
for($cnt = 0; $cnt<5; $cnt++){
// change code here
$_product = Mage::getModel('catalog/product')->load($result[$cnt]);
$my_product_url = $product->getProductUrl();
//or
$my_product_url=Mage::getResourceSingleton('catalog/product')
->getAttributeRawValue($result[$cnt], 'url_key', Mage::app()->getStore());
//or
$my_product_url=Mage::getUrl()''.$_product->getData('url_key').'.html';

PHP script works on localhost but not on webserver

I have this script.
<?php
$self=$_SERVER['PHP_SELF'];
$ipresurse='resurse.fibula.ro';
$PartnerID="travelplaza";
$SelectedAirport="ANTALYA";
function checkXmlCache($xmlQuery) {
$fibulabasexml="http://resurse.fibula.ro/parteneri/"; $cachedir="http://ydashopimpex.com/tmp"; $ageInSeconds = 3600;
$xmlQuery=str_replace(array("'",'"'),"",$xmlQuery); $xmlQuery2=$xmlQuery;
$long=array("stars=","TURKEY","bestprice=","country=", "location=","hotelcode=","prices=yes","tara=","simple=yes","rand()","sort=","limit=","price ","hotelname"," desc","desc");
$short=array("ST-","TR","B-","C-", "L-", "H-", "PY-", "T-", "-S-", "-R-", "S-", "LT-", "PP-","HN","-D","-D");
$xmlQuery2=str_replace($long,$short,$xmlQuery2);
$xmlQuery2=str_replace(array("xmlhotels.php","xmllocations.php"),array("XH-","XL-"),$xmlQuery2);
$xmlQuery2=str_replace(array("&","?"),array(""),$xmlQuery2);
$xmlQuery2.="_.XML";
$xmlQuery2=strip_tags($xmlQuery2);
if(!file_exists($cachedir.$xmlQuery2) || (filemtime($cachedir.$xmlQuery2) + $ageInSeconds < (time() )) ) {
$contents = file_get_contents($fibulabasexml.str_replace(" ","%20",$xmlQuery));
if(strlen($contents)>200 ) { file_put_contents($cachedir.$xmlQuery2, $contents); }
}
return($cachedir.$xmlQuery2);
}
function moneda($moneda) { $numemoneda=array("EURO","USD"); $simbol=array("€","$"); return str_replace($numemoneda,$simbol,$moneda); }
$feedbpl = checkXmlCache('xmlhotels.php?airport='.$SelectedAirport.'&myid=travelplaza'.$PartnerID.'&simple=yes&sort=nume asc');
$bpl = simplexml_load_file($feedbpl); $sh="0"; if(isset($_GET['code'])) { $codes=explode(",",$_GET['code']); $sh=strip_tags($codes[2]); }
?>
<div style="padding:2px; text-align:center">
<form name="fastsearch" method="get" action="<?php print $self; ?>">
<strong>CAUTARE RAPIDA HOTEL</strong> <select name="code" onchange="submit()" style="padding:2px 1px;"><option value="">---selecteaza hotel---</option><?php
foreach ($bpl->hotel as $h)
{
?><option <?php if($h['hotelcode']==$sh) { ?> selected="selected" <?php }?> value="<?php print $h['hotelname'].",".$h['location'].",".$h['hotelcode'];?>" title="<?php print $h['hotelname']." ".$h['stars'];?>"><?php print substr($h['hotelname'],0,30)." ".$h['stars'];?></option><?php
}
?>
</select></form>
</div>
<?php
if(!isset($_GET['code']))
{
/*
?>
<iframe style="padding:0px; margin:0px;" src='http://<?php print $ipresurse?>/WL/?myid=travelplaza<?php print $PartnerID; ?>&small=1' frameborder='0' width='100%' height='380' scrolling='auto'></iframe>
<?php
*/
}
if(isset($_GET['code']))
{
$feedurl =checkXmlCache("xmlhotels.php?hotelcode=".$sh."&prices=yes&myid=travelplaza".$PartnerID); $xml = simplexml_load_file($feedurl);
?>
<h1><?php print $xml->hotel['hotelname']; ?> <?php print $xml->hotel['stars']; ?></h1>
<div class="localizare"><?php print $xml->hotel['location']; ?> / <?php print $xml->hotel['country']; ?>
<div style="float:right; background-color:#C9F; color:white; -moz-border-radius: 10px; border-radius: 10px; font-weight:bold; padding:5px; text-align:center">REZERVA ACUM<br />de la <?php print floatval($xml->hotel['bestprice']). " " .moneda($xml->hotel['currency']); ?></div>
</div>
<div class="gallery" style="display:inline-table; width:100%;">
<img style="float:left" src="http://resurse.fibula.ro/hotel_images/<?php print $xml->hotel['hotelcode']."___".$xml->hotel['defaultimage'].".jpg"; ?>" alt="" width="350" />
<?php
foreach($xml->hotel->images->image as $img)
{
?>
<p style="float:left; margin:0px; padding:0px;"><a title="<?php print $xml->hotel['hotelname']; ?>" href="<?php print $img['url'];?>" rel="gallery">
<img style="float:left" src="<?php print str_replace(".jpg","___small.jpg",$img['url']);?>" alt="<?php print $xml->hotel['hotelname']; ?>" title="<?php print $xml->hotel['hotelname']; ?>" width="50" height="38"/></a>
</p>
<?php
}
?>
</div>
<?php print html_entity_decode($xml->hotel->description); ?>
<div style="display:inline-table; width:100%;" id="rezervare123">
<h4 >Rezerva acum ! Oferta de la <?php print floatval($xml->hotel['bestprice']). " " .moneda($xml->hotel['currency']); ?> </h4>
<?php /* ?>
<iframe style="padding:0px; margin:0px;" src='http://<?php print $ipresurse?>/WL/?myid=travelplaza<?php print $PartnerID; ?>&small=1&hotelcode=<?php print $xml->hotel['hotelcode']?>&hotel=<?php print $xml->hotel['hotelname']?>' frameborder='0' width='100%' height='380' scrolling='auto'></iframe>
<?php */ ?>
</div>
<?php
/*
foreach($xml->hotel->prices->bestPrice as $prices)
{
$capete[trim($prices['depAirport']."-".$prices['arrAirport'])][trim($prices['night'])]=trim($prices['night']);
$tarife[trim($prices['depAirport']."-".$prices['arrAirport'])][trim($prices['checkin'])][trim($prices['night'])]=number_format(floatval($prices['price']),0);
}
*/
//new tarife
$DefaultDiscount=0;
foreach($xml->hotel->prices->bestPrice as $prices) { $customprice=floatval($prices['price'])-$DefaultDiscount; $capete[trim($prices['depAirport']."-".$prices['arrAirport'])][trim($prices['night'])]=trim($prices['night']); $tarife[trim($prices['depAirport']."-".$prices['arrAirport'])][trim($prices['checkin'])][trim($prices['night'])]=$customprice; }
?>
<!-- prices start -->
<?php
foreach($capete as $key=>$value){ asort($value);
?>
<div id="<?php print $key; ?>" style="padding:0px;" class="content">
<p></p>
<table width="100%"><thead>
<tr><td width="10%">Data plecare</td>
<?php foreach($value as $n) { ?><td><?php print $n;?></td><?php }?>
</tr>
<thead><tbody>
<tr><td colspan="<?php print count($value)+1; ?>" align="center"><span style="color: #ff6600; font-weight:bold;">
Tarife de persoana in camera standard. (* tarifele nu includ taxele de aeroport 95€/pers)
</span>
</td></tr>
<?php foreach($tarife[$key] as $checkin=>$nn) { $chk=new DateTime($checkin); ?>
<tr><td><?php print $chk->format('d.m.Y');?></td><?php
foreach($value as $n) { ?><td align="right"> <?php if(array_key_exists($n,$nn)) { print $nn[$n];} ?></td><?php } ?>
</tr><?php
}
?>
</tbody>
</table>
</div>
<?php
}
?>
<?php
/*
foreach ($tarife as $rute=>$plecari)
{ sort($capete[$rute]); $ut=0; $i=0;
foreach($plecari as $plecare=>$tarif)
{ $sd=explode("-",$plecare); if($ut!=$tarif[$capete[$rute][0]]) {$i++; }
${str_replace("-","_",$rute)}[$tarif[$capete[$rute][0]]."|".$i][]=$sd[2].".".$sd[1];
$ut=$tarif[$capete[$rute][0]];
}
}
foreach($capete as $rute=>$value)
{
?>
<h4>Oferta <?php print $rute. " ".$value[0]." nopti"; ?></h4>
<table style="font-size:10px; border-collapse:collapse; " border="1" width="100%"><tr><?php
foreach(${str_replace("-","_",$rute)} as $key=>$value)
{ ?><td valign="bottom" align="center" style=" border-collapse:collapse; "><?php foreach($value as $dep) { print $dep."<br>";}?></td><?php }
?></tr><tr><?php
foreach(${str_replace("-","_",$rute)} as $key=>$value)
{ $t=explode("|",$key); ?><td style=" background-color:lightblue; border-collapse:collapse; text-align:center;"><?php print $t[0];?></td><?php }
?>
</tr></table>
<?php unset(${str_replace("-","_",$rute)});
}
*/
?>
<!-- end of prices -->
<?php
}
else
{
$feedurl =checkXmlCache('xmllocations.php?country=TURKEY&myid=travelplaza'.$PartnerID); $locations = simplexml_load_file($feedurl);
foreach($locations->country->location as $x) { $airs[trim($x['airport'])][]=$x; }
$xxx=0; $HotelsPerPage=15; $pagini=ceil($bpl['offers']/$HotelsPerPage); $pc=1; $maxi=$HotelsPerPage; $mini=1;
if(isset($_GET['pagina'])) {$pc=intval($_GET['pagina']); $maxi=$pc*$HotelsPerPage; $mini=$maxi-$HotelsPerPage+1; }
foreach ($bpl->hotel as $hbpl)
{
$xxx++;
if( ($xxx<=$maxi) and ($xxx>=$mini) )
{
$locatie=$hbpl['location'];
$imageurl="http://".$ipresurse."/hotel_images/".$hbpl['hotelcode']."___".$hbpl['defaultimage']."___medium.jpg";
$l=0; $locationLink=$self."?";
foreach($_GET as $k=>$v)
{ $l++; $si="&"; if($l==1) { $si=""; }
if( ($k!='location') and ($k!='nopti') and ($k!='hotel') and ($k!='hotelcode') and ($k!='ruta') ) { $locationLink.=$si.$k."=".$v; }
}
if($hbpl['airport']=='ANTALYA') {$linkruta="OTP_AYT";} else {$linkruta="OTP_BJV";}
$hotelLink=$self."?code=".urlencode($hbpl['hotelname']).",".$hbpl['location'].",".$hbpl['hotelcode'];
?>
<div class="box">
<div class="thumb"><img width="330" height="220" src="<?php print $imageurl; ?>" class="attachment-post-thumbnail wp-post-image" alt="<?php print $hbpl['hotelname'] ?>" title="<?php print $hbpl['hotelname'] ?>" /></div>
<a class="box-title" href="<?php print $hotelLink; ?>"><?php print $hbpl['hotelname'] ?> <?php print $hbpl['stars']; ?> <?php print number_format(floatval($hbpl['bestprice']))." ".moneda($hbpl['currency']); ?></a>
<a class="button" href="<?php print $hotelLink; ?>">Afla mai multe</a>
</div>
<?php
}
}
?>
<div style=" display: inline-block; width:100%;"> </div>
<div style="border-top:solid 1px #ccc; display:inline-table; width:100%;" align="center">
<?php
if($pc>1) { ?>
<span style=" float:left; padding:1px; margin:1px; background-color:#ccc;"><a style="text-decoration:none" href="<?php print $self."?pagina=".($pc-1); ?>">« Inapoi</a></span><?php }
for($i=1; $i<=$pagini; $i++)
{
?><span style=" float:left; padding:0px; margin:1px; border:solid 1px #ccc; <?php if($i==$pc) { ?> background-color:#ccc; <?php }?>" >
<a style="text-decoration:none; padding:0px 2px; margin:0px; line-height:10px;" href="<?php if($i==$pc) { print "#"; } else { print $self."?pagina=".$i;} ?>"><?php print $i;?></a>
</span><?php
}
if($pc<$pagini) { ?><span style=" float:left; padding:1px; margin:1px; background-color:#ccc;"><a style="text-decoration:none" href="<?php print $self."?pagina=".($pc+1); ?>">Inainte » </a></span><?php }
?>
</div>
<?php
}
?>
On my localhost it works.
But when I upload it to the servers it reads only the html.
Picture attached. Any idea of what it can be wrong? Maybe a php function on the server that might be disabled? What should I check? I have spoken with my webhost and he told me that I must know which function I need.
You can use ini_set and error_reporting to set the PHP Error Reporting to ALL and other error related ini settings.
i.e:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
Also, as mentioned in the comments, create a php file holding the phpinfo() command to see weather or not php is running on your server at all.
testphp.php
<?php
phpinfo();
If you open yourwebsitesdomain.com/testphp.php and you do not see information on php running, contact your webhoster and tell him php is not working on the server.

Categories