In order to test if the converted index.haml would work on with my wamp and localhost i did the following:
First, I renamed my index.php into index.html
Then, I typed html2haml index.html index.haml in the command line
Then, I typed haml index.haml indexnew.html in the command line
I renamed indexnew.html to indexnew.php
I tested it: localhost/projects/cross-browser/base0.9/indexnew.php
but the indexnew.php was rendered blank even if the code inside is ok:
Original Php (index.php):
<?php
include_once 'localization.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<title>Alex Chen - Web Development, Graphic Design, and Translation</title>
<link rel="stylesheet" type="text/css" href="styles/reset.css" />
<link rel="stylesheet" type="text/css" href="styles/global.css" />
<link rel="stylesheet" type="text/css" href="fancybox/jquery.fancybox-1.3.1.css" />
<?php if($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" />';} ?>
<script type="text/javascript" src="scripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="scripts/jquery.validate.js"></script>
<script type="text/javascript" src="fancybox/jquery.fancybox-1.3.1.pack.js"></script>
<script type="text/javascript" src="scripts/jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="scripts/jquery.localscroll-min.js"></script>
<script type="text/javascript" src="scripts/custom.js"></script>
<?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js"></script>';} ?>
<?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js"></script>';} ?>
<?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js"></script>';} ?>
<?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js"></script>';} ?>
</head>
<body id="home">
<div id="header">
<div class="container">
<div id="banner">
<ul id="lang">
<li <?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>>ENGLISH</li>
<li <?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>><?php echo l('nav_a0'); ?></li>
<li <?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>><?php echo l('nav_a1'); ?></li>
<li <?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>><?php echo l('nav_a2'); ?></li>
</ul>
<div id="logo">
<h1><a>ALEXCHEN</a></h1>
</div>
<div id="logo2">
<ul id="nav">
<li><?php echo l('nav1'); ?></li>
<li><?php echo l('nav2'); ?></li>
</ul>
</div>
<div id="logo3">
</div>
</div><!-- #header-bottom -->
</div><!-- .container -->
</div><!-- #header -->
<div id="content">
<div class="container">
<div class="showcase">
<div class="first">
<div id="nopic">
<p><?php echo l('tagline_p'); ?></p>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase1_h3'); ?></h3>
<p><?php echo l('showcase1_p'); ?></p>
<div class="pic">
<a id="showcase1" href="#inline1"><img src="images/showcase1t.png"/></a>
<div id="inline1">
<img src="images/showcase1.png"/>
studyatbest.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase2_h3'); ?></h3>
<p><?php echo l('showcase2_p'); ?></p>
<div class="pic">
<a id="showcase2" href="#inline2"><img src="images/showcase2t.png"/></a>
<div id="inline2">
<img src="images/showcase2.png"/>
spacestudios.com
</div>
</div>
</div><!-- .pushed -->
<div class="pusher">
<h3><?php echo l('showcase3_h3'); ?></h3>
<p><?php echo l('showcase3_p'); ?></p>
<div class="pic">
<a id="showcase3" href="#inline3"><img src="images/showcase3t.png"/></a>
<div id="inline3">
<img src="images/showcase3.png"/>
alexchen.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase4_h3'); ?></h3>
<p><?php echo l('showcase4_p'); ?></p>
<div class="pic">
<a id="showcase4" href="#inline4"><img src="images/showcase4t.png"/></a>
<div id="inline4">
<img src="images/showcase4.png"/>
mattsai.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase5_h3'); ?></h3>
<p><?php echo l('showcase5_p'); ?></p>
<div class="pic">
<a id="showcase5" href="#inline5"><img src="images/showcase5t.png"/></a>
<div id="inline5">
<img src="images/showcase5.png"/>
mattsai.com
</div>
</div>
</div><!-- .pusher -->
<div class="pusher">
<h3><?php echo l('showcase6_h3'); ?></h3>
<p><?php echo l('showcase6_p'); ?></p>
<div class="pic">
<a id="showcase6" href="#inline6"><img src="images/showcase6t.png"/></a>
<div id="inline6">
<img src="images/showcase6.png"/>
mattsai.com
</div>
</div>
</div>
<div class="pusher">
<h3><?php echo l('showcase8_h3'); ?></h3>
<p><?php echo l('showcase8_p'); ?></p>
<div class="pic">
<a id="showcase8" href="#inline8"><img src="images/showcase8t.png"/></a>
<div id="inline8">
<img src="images/showcase8.png"/>
mattsai.com
</div>
</div>
</div><!-- .pusher -->
</div><!-- .showcase -->
</div><!-- .container -->
</div><!-- #work -->
<div id="footer">
<div class="container">
<div id="footer-top">
<div id="about">
<h3><?php echo l('about_h3'); ?></h3>
<p><?php echo l('about_p'); ?></p>
</div>
<div id="info">
<h3><?php echo l('info_h3'); ?></h3>
<ul>
<li id="tel"><?php echo l('_info_li2'); ?><p>Tel:</p> 0918051170</li>
<li id="gmail"><?php echo l('_info_li3'); ?><p></p>alexchen.net#gmail.com</li>
<li id="facebook"><?php echo l('_info_li4'); ?> facebook</li>
</ul>
</div>
<div id="contact">
<h3><?php echo l('contact_h3'); ?></h3>
<p><?php echo l('_contact_p'); ?></p>
<form id="sendmail" method="post" action="http://www.emailmeform.com/fid.php?formid=254816">
<label for="name"><?php echo l('form_label1'); ?></label>
<input type="text" id="name" name="FieldData0" />
<label for="email"><?php echo l('form_label2'); ?></label>
<input type="text" id="email" name="FieldData1" />
<label for="message"><?php echo l('form_label3'); ?></label>
<textarea type="text" id="message" name="FieldData2"></textarea>
<input id="button" type="submit" value="<?php echo l('submit'); ?>">
</form>
</div>
</div><!-- #footer-top -->
<div id="footer-bottom">
<p>Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on Zymic. Contact form hosted on Email Me Form.<a id="nr" href="http://www.freedomain.co.nr/cheap_web_hosting.php" target="_blank"><img src="http://ruarmza.4u.com.ru/ch.gif" alt="Cheap Web Hosting Providers" width="88" height="31" border="0" /></a></p>
</div>
</div><!-- .container -->
</div><!-- #footer -->
<script type="text/javascript" src="scripts/google-analytics.js"></script>
<script type="text/javascript" src="scripts/page-tracker.js"></script>
</body>
</html>
Converted Php (indexnew.php):
<?php include_once 'localization.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
<meta content='IE=EmulateIE7' http-equiv='X-UA-Compatible' />
<title>Alex Chen - Web Development, Graphic Design, and Translation</title>
<link href='styles/reset.css' rel='stylesheet' type='text/css' />
<link href='styles/global.css' rel='stylesheet' type='text/css' />
<link href='fancybox/jquery.fancybox-1.3.1.css' rel='stylesheet' type='text/css' />
<?php if($lang_file=='lang.zh-tw.php' || $lang_file=='lang.zh-cn.php') {echo '<link rel="stylesheet" type="text/css" href="styles/chinese.css" ?>
';} ?>
<script src='scripts/jquery-1.3.2.min.js' type='text/javascript'></script>
<script src='scripts/jquery.validate.js' type='text/javascript'></script>
<script src='fancybox/jquery.fancybox-1.3.1.pack.js' type='text/javascript'></script>
<script src='scripts/jquery.scrollTo-min.js' type='text/javascript'></script>
<script src='scripts/jquery.localscroll-min.js' type='text/javascript'></script>
<script src='scripts/custom.js' type='text/javascript'></script>
<?php if($lang_file=='lang.en.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-en.js?>
';} ?>
<?php if($lang_file=='lang.es.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-es.js?>
';} ?>
<?php if($lang_file=='lang.zh-tw.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-tw.js?>
';} ?>
<?php if($lang_file=='lang.zh-cn.php') {echo '<script type="text/javascript" src="scripts/jquery-validate/val-zh-cn.js?>
';} ?>
</head>
<body id='home'>
<div id='header'>
<div class='container'>
<div id='banner'>
<ul id='lang'>
<li
<?php if($lang_file=='lang.en.php') {echo 'class="current"';} ?>
>
</ul>
<a href='index.php?lang=en'>ENGLISH</a>
<li
<?php if($lang_file=='lang.es.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=es'>
<?php echo l('nav_a0'); ?>
</a>
<li
<?php if($lang_file=='lang.zh-tw.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=zh-tw'>
<?php echo l('nav_a1'); ?>
</a>
<li
<?php if($lang_file=='lang.zh-cn.php') {echo 'class="current"';} ?>
>
<a href='index.php?lang=zh-cn'>
<?php echo l('nav_a2'); ?>
</a>
<div id='logo'>
<h1>
<a>ALEXCHEN</a>
</h1>
</div>
<div id='logo2'>
<ul id='nav'>
<li>
<a href='#content'>
<?php echo l('nav1'); ?>
</a>
</li>
<li>
<a href='#contact'>
<?php echo l('nav2'); ?>
</a>
</li>
</ul>
</div>
<div id='logo3'></div>
</div>
<!-- #header-bottom -->
</div>
<!-- .container -->
</div>
<!-- #header -->
<div id='content'>
<div class='container'>
<div class='showcase'>
<div class='first'>
<div id='nopic'>
<p>
<?php echo l('tagline_p'); ?>
</p>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase1_h3'); ?>
</h3>
<p>
<?php echo l('showcase1_p'); ?>
</p>
<div class='pic'>
<a href='#inline1' id='showcase1'>
<img src='images/showcase1t.png' />
</a>
<div id='inline1'>
<img src='images/showcase1.png' />
<a href='http://studyatbest.com'>studyatbest.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase2_h3'); ?>
</h3>
<p>
<?php echo l('showcase2_p'); ?>
</p>
<div class='pic'>
<a href='#inline2' id='showcase2'>
<img src='images/showcase2t.png' />
</a>
<div id='inline2'>
<img src='images/showcase2.png' />
<a href='http://studyatbes.com'>spacestudios.com</a>
</div>
</div>
</div>
<!-- .pushed -->
<div class='pusher'>
<h3>
<?php echo l('showcase3_h3'); ?>
</h3>
<p>
<?php echo l('showcase3_p'); ?>
</p>
<div class='pic'>
<a href='#inline3' id='showcase3'>
<img src='images/showcase3t.png' />
</a>
<div id='inline3'>
<img src='images/showcase3.png' />
<a href='http://studyatbes.com'>alexchen.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase4_h3'); ?>
</h3>
<p>
<?php echo l('showcase4_p'); ?>
</p>
<div class='pic'>
<a href='#inline4' id='showcase4'>
<img src='images/showcase4t.png' />
</a>
<div id='inline4'>
<img src='images/showcase4.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase5_h3'); ?>
</h3>
<p>
<?php echo l('showcase5_p'); ?>
</p>
<div class='pic'>
<a href='#inline5' id='showcase5'>
<img src='images/showcase5t.png' />
</a>
<div id='inline5'>
<img src='images/showcase5.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<!-- .pusher -->
<div class='pusher'>
<h3>
<?php echo l('showcase6_h3'); ?>
</h3>
<p>
<?php echo l('showcase6_p'); ?>
</p>
<div class='pic'>
<a href='#inline6' id='showcase6'>
<img src='images/showcase6t.png' />
</a>
<div id='inline6'>
<img src='images/showcase6.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<div class='pusher'>
<h3>
<?php echo l('showcase8_h3'); ?>
</h3>
<p>
<?php echo l('showcase8_p'); ?>
</p>
<div class='pic'>
<a href='#inline8' id='showcase8'>
<img src='images/showcase8t.png' />
</a>
<div id='inline8'>
<img src='images/showcase8.png' />
<a href='http://studyatbes.com'>mattsai.com</a>
</div>
</div>
</div>
<!-- .pusher -->
</div>
<!-- .showcase -->
</div>
<!-- .container -->
</div>
<!-- #work -->
<div id='footer'>
<div class='container'>
<div id='footer-top'>
<div id='about'>
<h3>
<?php echo l('about_h3'); ?>
</h3>
<p>
<?php echo l('about_p'); ?>
</p>
</div>
<div id='info'>
<h3>
<?php echo l('info_h3'); ?>
</h3>
<ul>
<li id='tel'>
<?php echo l('_info_li2'); ?>
<p>Tel:</p>
0918051170
</li>
<li id='gmail'>
<?php echo l('_info_li3'); ?>
<p></p>
<a href='mailto:janoochen#gmail.com'>alexchen.net#gmail.com</a>
</li>
<li id='facebook'>
<?php echo l('_info_li4'); ?>
<a href='http://www.facebook.com/weedd.chen'>facebook</a>
</li>
</ul>
</div>
<div id='contact'>
<h3>
<?php echo l('contact_h3'); ?>
</h3>
<p>
<?php echo l('_contact_p'); ?>
</p>
<form action='http://www.emailmeform.com/fid.php?formid=254816' id='sendmail' method='post'>
<label for='name'>
<?php echo l('form_label1'); ?>
</label>
<input id='name' name='FieldData0' type='text' />
<label for='email'>
<?php echo l('form_label2'); ?>
</label>
<input id='email' name='FieldData1' type='text' />
<label for='message'>
<?php echo l('form_label3'); ?>
</label>
<textarea id='message' name='FieldData2' type='text'></textarea>
<input id='button' type='submit' value="<?php echo l('submit'); ?>" />
</form>
</div>
</div>
<!-- #footer-top -->
<div id='footer-bottom'>
<p>
Copyright © 2010 Alex Chen. All Rights Reserved. Hosted on
<a href='http://www.zymic.com'>Zymic</a>.
Contact form hosted on
<a href='http://www.emailmeform.com'>Email Me Form</a>.
<a href='http://www.freedomain.co.nr/cheap_web_hosting.php' id='nr' target='_blank'>
<img alt='Cheap Web Hosting Providers' border='0' height='31' src='http://ruarmza.4u.com.ru/ch.gif' width='88' />
</a>
</p>
</div>
</div>
<!-- .container -->
</div>
<!-- #footer -->
<script src='scripts/google-analytics.js' type='text/javascript'></script>
<script src='scripts/page-tracker.js' type='text/javascript'></script>
</body>
</html>
Any suggestions?
I'd suggest you try a PHP-specific version of HAML, like PHPHaml or pHAML. The Ruby HAML interpreter is specifically expecting Ruby code, and will likely screw up your PHP syntax.
Having said that, I have used Chaml with some degree of success. HAML for PHP is at a rather experimental stage, and you will come across bugs. If you're writing more HTML than PHP though, it can be a great help.
Related
I have to following php code where I want to execute the image function if there is an image to show. Which means If the image field is empty/NULL I dont want to show the image, because it will give an error saying 'no image found'.
How can I do this?
Thanks in advance.
<div>
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct2'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct2']);?>" class="img-fluid" alt="Product2" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct3'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct3']);?>" class="img-fluid" alt="Product3" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct4'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct4']);?>" class="img-fluid" alt="Product4" />
<?php } ?>
</div>
(Goes till imgProduct8)
In the Database image, I have my picture data ready. In the last line you see imgProduct1 filled, imgProduct2 filled, imgProduct3 filled. After that imgProduct4 is NULL, so I dont want to execute the image function for that matter.
Database image:
In Result from the database picture, you see the result I am getting. So again imgProduct1, imgProduct2 and imgProduct3 are filled with a link, imgProduct4, imgProduct5 etc are not. So I dont want to show the image, thats not there.
Result from database:
The result I am getting now is 3 pictures in my slide show and after that just blank pictures. So he is still think there are more pictures to show.
my whole code:
<?php
require('../php/connection.php');
$product = $_GET['product'];
$sql = "SELECT * FROM tblproduct WHERE strProductNaam='$product'";
$result = sqlsrv_query($conn,$sql);
if( $result === false ) {
die( print_r( sqlsrv_errors(), true));
}
while($row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC)) {
$datas[] = $row;
}
echo '<pre>';
print_r($datas);
echo '</pre>';
sqlsrv_free_stmt($result);
sqlsrv_close($conn);
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Home Gym</title>
<?php
include('../structure/effects.php');
?>
</head>
<body>
<!-- Header -->
<?php
include('../structure/header.php');
?>
<!-- /Header -->
<!-- Main -->
<main>
<br>
<!-- Product Section -->
<section class="single-product">
<div class="container">
<div class="row">
<div class="col-md-5">
<div class="container-fluid p-0">
<div class="site-slider">
<div class="slider-one">
<div>
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct2'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct2']);?>" class="img-fluid" alt="Product2" />
<?php } ?>
</div>
<div>
<?php if (!empty($datas[0]['imgProduct3'])){ ?>
<img src="<?php echo ($datas[0]['imgProduct3']);?>" class="img-fluid" alt="Product3" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct4']);?>" class="img-fluid" alt="Product4" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct5']);?>" class="img-fluid" alt="Product5" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct6']);?>" class="img-fluid" alt="Product6" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct7']);?>" class="img-fluid" alt="Product7" />
<?php } ?>
</div>
<div>
<?php if (($datas[0]['imgProduct4']) !== NULL){ ?>
<img src="<?php echo ($datas[0]['imgProduct8']);?>" class="img-fluid" alt="Product8" />
<?php } ?>
</div>
</div>
<div class="slider-button">
<span class="prev position-top"><i class="fas fa-chevron-left"></i></span>
<span class="next position-top right-0"><i class="fas fa-chevron-right"></i></span>
</div>
</div>
</div>
</div>
<div class="col-md-7">
<p class="new-arrival text-center">NEW</p>
<div class="product-bottom">
<p><i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
</p>
<p><h3><?php echo ($datas[0]['strProductNaam']); ?></h3></p>
<p class="price"><h5><s>€<?php echo ($datas[0]['intPrijs']); ?></s> <b><span class="make_red">€<?php echo ($datas[0]['strSalePrijs']); ?></span> </b></h5></p>
<p><b>Availability: </b>In Stock</p>
</div>
<div class="positive">
<p><i class="fa fa-plus" aria-hidden="true"></i> <?php echo ($datas[0]['strPlusPunt1']); ?></p>
<p><i class="fa fa-plus" aria-hidden="true"></i> <?php echo ($datas[0]['strPlusPunt2']); ?></p>
</div>
<div class="negative">
</div>
<label>Quantity: </label>
<input class="text-center" type="text" value="1"></input>
<button type="button" class="btn btn-primary">Add to Cart</button>
<table class="content-table">
<thead>
<tr>
<th>Product Specifications</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Type</td>
<td><?php echo ($datas[0]['strSpecSoort']); ?></td>
</tr>
<tr class="active-row">
<td>Guarantee</td>
<td><?php echo ($datas[0]['strSpecGarantie']); ?></td>
</tr>
<tr>
<td>Material</td>
<td><?php echo ($datas[0]['strSpecMateriaal']); ?></td>
</tr>
<tr class="active-row">
<td>Weight</td>
<td><?php echo ($datas[0]['strGewicht']); ?></td>
</tr>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</section>
<!-- /Product Section -->
<!-- Product Description -->
<section class="product-description">
<div class="container">
<h6>Product Description</h6>
<p><?php echo ($datas[0]['strBeschrijving']); ?></p>
</div>
</section>
<!-- /Product Descriptionn -->
<br>
<hr class="hr">
<!-- On Sale Product -->
<?php
include('../product-sale.php');
?>
<!-- /On Sale Product -->
</main>
<!-- /Main -->
<!-- Footer -->
<?php
include('../structure/footer.php');
?>
<!-- /Footer -->
<!-- Script: Bootstrap CDN, JS -->
<?php
include('../structure/script.php');
?>
</body>
</html>
you can try updating the query:
SELECT * FROM table_name WHERE image_column != NULL
Hope so it might help you. It would be better if you provide the whole code...
SOLVED:
<?php if (!empty($datas[0]['imgProduct1'])){ ?>
<div>
<img src="<?php echo ($datas[0]['imgProduct1']);?>" class="img-fluid" alt="Product1" />
</div>
<?php } ?>
The div had to be inside of the if function. That's why a white screen popped up.
I have been trying to make a website. It is an online shopping website.
This is my code-
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Books And Beyond</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap styles open source -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" crossorigin="anonymus">
<!-- Customize styles -->
<link href="style.css" rel="stylesheet"/>
<!-- font awesome styles open source -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" crossorigin="anonymus">
<!-- Favicons -->
<link rel="shortcut icon" href="/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style
type="text/css">
<!--
body {
background-image: url(assets/img/background.jpg);
}
-->
</style></head>
<body>
<!--
Upper Header Section
-->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="topNav">
<div class="container">
<div class="alignR">
<?php if (isset($_SESSION['email'])) { echo $_SESSION['email']; } else { ?>
<ul class="nav pull-right">
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#"><span class="icon-lock"></span> Login <b class="caret"></b></a>
<div class="dropdown-menu">
<form class="form-horizontal loginFrm" action="checkuser.php" method="post">
<div class="control-group">
<input name="email" type="text" class="span2" id="email" placeholder="Email">
</div>
<div class="control-group">
<input name="password" type="password" class="span2" id="password" placeholder="Password">
</div>
<div class="control-group">
<label class="checkbox">
<input type="checkbox"> Remember me
</label>
<button name="login" type="submit" class="shopBtn btn-block">Sign in</button>
</div>
</form>
</div>
</li>
</ul>
<?php } ?>
<?php if (isset($_SESSION['email'])) { ?>
Logout
<?php } else { ?>
<span class="icon-edit"></span> Register
<?php }?>
</div>
</div>
</div>
</div>
<!--
Lower Header Section
-->
<div class="container">
<div id="gototop"> </div>
<header id="header">
<div class="row">
<div class="span4">
<h1>
<a class="logo" href="index.php"><span>Books And Beyond</span>
<img src="assets/img/logo1.jpg" alt="" width="218" height="94"> </a> </h1>
</div>
</div>
</header>
<!--
Navigation Bar Section
-->
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="nav-collapse">
<ul class="nav">
<li class="active">Home</li>
<li class="">About</li>
<li class="">Bargain Books</li>
<li class="">New Releases</li>
<li class="">Bestsellers</li>
<li class="">Contact Us</li>
</ul>
<ul class="nav pull-right">
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span12">
<img src="assets/img/banner.jpg"/>
<hr class="soften"/>
</div>
</div>
<!--Body Section
-->
<div class="row">
<div id="sidebar" class="span3">
<div class="well well-small">
<h3> Category </h3>
<ul class="nav nav-list">
<li><span class="icon-chevron-right"></span>Fiction</li>
<li><span class="icon-chevron-right"></span>Non-Fiction</li>
<li><span class="icon-chevron-right"></span>Young Adult</li>
<li><span class="icon-chevron-right"></span>Children's</li>
<li><span class="icon-chevron-right"></span>Travel</li>
<li><span class="icon-chevron-right"></span>Education</li>
<li style="border:0"> </li>
</ul>
</div>
<!--<div class="well well-small alert alert-warning cntr">
<h2>50% Discount</h2>
<p>
only valid for online order. <br><br><a class="defaultBtn" href="#">Click here </a>
</p>
</div>-->
<!-- <div class="well well-small" ><img src="assets/img/paypal.jpg" alt="payment method paypal"></div>-->
<!--<a class="shopBtn btn-block" href="#">Upcoming products <br><small>Click to view</small></a>-->
<ul class="nav nav-list promowrapper">
<?php
/* require_once('dbconnect.php'); */
$result = mysql_query("SELECT * from product WHERE brand='accessories'");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li>
<div class="thumbnail">
<img width="200" height="80" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption">
<table width="250" border="0">
<tr>
<td align="left" valign="middle"><form action="product_detail.php" method="post" name="form2" id="form2">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
</label>
</form></td>
<td align="right" valign="middle"><h4> <span class="pull-right"><?php echo $price; ?>.00</span></h4></td>
</tr>
</table>
</div>
</div>
</li>
<li style="border:0"> </li>
<?php } ?>
</ul>
</div>
<div class="span9">
<!--
New Products
-->
<div class="well well-small">
<h3>New Products </h3>
<hr class="soften"/>
<div class="row-fluid">
<div id="newProductcar" class="carousel slide">
<div class="">
<div class="item active">
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='bousni' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='hela couture' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='zey' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='AL-JUMAIRA' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="well well-small">
<div class="span8">
<div class="row-fluid">
<h3>Features Products </h3>
<hr class="soften"/>
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='roza' LIMIT 3");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$productname=$row["productname"];
$brand=$row["brand"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li class="span4">
<div class="thumbnail">
<img width="250" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption cntr">
<p style="color:#990033"><?php echo $productname; ?></p>
<p><?php echo $brand; ?></p>
<p><strong>SAR <?php echo $price; ?>.00</strong></p>
<div class="btn-group">
<form id="form2" name="form2" method="post" action="product_detail.php">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
<input name="Submit2" type="submit" class="defaultBtn" value="Add to cart" />
</label>
</form>
</div>
<br class="clr">
</div>
</div>
</li>
<?php } ?>
</ul>
<hr class="soften"/>
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='haya' LIMIT 3");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$productname=$row["productname"];
$brand=$row["brand"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li class="span4">
<div class="thumbnail">
<img width="250" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption cntr">
<p style="color:#990033"><?php echo $productname; ?></p>
<p><?php echo $brand; ?></p>
<p><strong>SAR <?php echo $price; ?>.00</strong></p>
<div class="btn-group">
<form id="form2" name="form2" method="post" action="product_detail.php">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
<input name="Submit2" type="submit" class="defaultBtn" value="Add to cart" />
</label>
</form>
</div>
<br class="clr">
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
<div class="row">
</div>
</div>
</div></div></div>
<!--
Footer
-->
<footer class="footer" style="float: bottom;">
<div class="row-fluid">
<div class="span3">
<h5>ORDER SUPPORT</h5>
Store pickup<br>
Return and Refund<br>
</div>
<div class="span3">
<h5>PRODUCT SUPPORT</h5>
FAQs<br>
Inquiry<br>
</div>
<div class="span3">
<h5>COOPORATIVE INFO</h5>
Terms and Condition <br>
Contact us<br>
</div>
<div class="span3">
<h5>GET CONNECTED</h5>
About us <br>
Create Account<br>
</div>
</div>
</footer>
</div><!-- /container -->
<div class="copyright">
<div class="container">
<p class="pull-right"> </p>
<span>Copyright 2019, Fatimatuz Johura - s201403034- Jeddah (Ladies Branch);<br> Books And Beyond</span>
</div>
</div>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.easing-1.3.min.js"></script>
<script src="assets/js/jquery.scrollTo-1.4.3.1-min.js"></script>
<script src="assets/js/shop.js"></script>
</body>
</html>
The 'New Products' and the footer section is not coming and I cant figure out why. I dont have a webhost yet so I am using localhost for now. I have tried editing the code but whatever I do, it does not seem to work. If anyone can help, I would really appreciate it. Thank you.
On line 152 (new products is on line ~ 185[ish])
/* require_once('dbconnect.php'); */
$result = mysql_query("SELECT * from product WHERE brand='accessories'");
As I said in the comments you use this require_once('dbconnect.php'); multiple times when it should be only once at the top of your file.
The above code is the first occurrence I could find, and as it's commented out, that query is going to bomb out on you. Execution happens top to bottom and the first uncommitted occurrence of that is line 196[ish], which is way to late for that first query.
Also as I said in the comments
Try turning on Error reporting - error_reporting(-1); and ini_set('display_errors', '1'); put those right after the <?php tag
You can save yourself, and us a lot of time that way.
So in Summery,
Remove all of these require_once('dbconnect.php'); and then add just one after the opening <?php tag.
PS you can easily test this, by just commenting that first query out, or by uncommenting that first require_once.
Hello I had a program written in php. I want select a category and shows articles related. I select one category but dont show a articule. Anybody helps me?
catalogo.php
<div class="col-md-4-fluid">
<form class="navbar-form navbar-left" role="search" action="buscartipo.php" method="post" enctype="multipart/form-data" class="pull-right">
<div class="input-group">
<select class="form-control" name="tipo">
<option value="" selected="selected">Buscar por tipo</option>
<option value="tecnologia">Llave T</option>
<option value="deportes">Herramientas especiales</option>
<option value="arte">Kit de puesta a punto</option>
<option value="viajes">Otros</option>
</select>
<span class="input-group-btn">
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
</span>
</div>
</form>
</div>
</div>
<!--Fin row buscadores-->
<!--Comienzo row ofertas-->
<div class="row" id="catalogo">
<?php
include "conexionnew.php";
if(isset($_SESSION['empleado'])){
$idempleado=$_SESSION['empleado']['id_usuario'];
$resultado=mysqli_query($conexion,"SELECT * FROM empleado where id_usuario!='$id_usuario'");
while($array=mysqli_fetch_array($resultado)){
?>
<div class="col-md-3">
<div class="thumbnail">
<a class="example-image-link" href='<?php echo($array['imagen']);?>' data-lightbox="example-set" data-title="Optional caption."><img class="example-image" src='<?php echo ($array['imagen']);?>' alt=""/></a>
<div class="caption">
<p><?php echo $array['descripcion'];?></p>
<h3><?php echo "$".$array['precio'];?></h3>
<?php echo "<p><a href='descripcion.php?id_plantilla=$array[id_plantilla]' class='btn btn-primary' role='button'>Comprar ahora</a></p>";?>
</div>
</div>
</div>
<?php
}
}else{
$resultado=mysqli_query($conexion,"SELECT * FROM articulo");
while($array=mysqli_fetch_array($resultado)){
?>
<div class="col-md-3">
<div class="thumbnail">
<a class="example-image-link" href='<?php echo($array['imagen']);?>' data-lightbox="example-set" data-title="Optional caption."><img class="example-image" src='<?php echo ($array['imagen']);?>' alt=""/></a>
<div class="caption">
<p><?php echo $array['codarticulo'];?></p>
<h3><?php echo "$".$array['precio'];?></h3>
<?php echo "<p><a href='descripcion.php?idarticulo=$array[idarticulo]' class='btn btn-primary' role='button'>Ver detalle</a></p>";?>
</div>
</div>
</div>
<?php
}
}
?>
<!--Fin row ofertas-->
</div>
</div>
the values is received by buscartipo.php
<?php
session_start();
$tipo=$_POST['tipo'];
if(empty($tipo)){
echo "<script>alert('Seleccione un tipo de plantilla')</script>";
echo "<script>location.href='catalogo.php'</script>";
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Inicio | F y F herramientas</title>
<!-- core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/prettyPhoto.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
<link href="css/responsive.css" rel="stylesheet">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.prettyPhoto.js"></script>
<script src="js/jquery.isotope.min.js"></script>
<script src="js/main.js"></script>
<script src="js/wow.min.js"></script>
<!-- para sweet alert2 -->
<script src="bower_components/es6-promise/es6-promise.auto.min.js"></script> <!-- for IE support -->
<script type="text/javascript" src="js/sweetalert2/dist/sweetalert2.min.js"></script>
<link rel="stylesheet" type="text/css" href="js/sweetalert2/dist/sweetalert2.min.css">
</head>
<body class="homepage">
<?php require_once('cabecera.php'); ?>
<section id="feature">
<div class="container">
<!--Container cabecera-->
<div class="container" id="contenido-cabecera">
<div id="titulo-cabecera">Articulos</div>
<p>Filtrado por tipo</p>
</div>
<!--Fin Container cabecera-->
<!--Comienzo container buscar por tipo-->
<div class="row" id="buscar-tipo">
<?php
include "conexionnew.php";
/*$id_articulo=$_SESSION['articulo']['idarticulo']; */
$resultado=mysqli_query($conexion,"SELECT * FROM articulo where tipo='$tipo'");
while($array=mysqli_fetch_array($resultado)){
if($array['idarticulo']!=$id_articulo){
?>
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<a class="example-image-link" href='<?php echo($array['imagen']);?>' data-lightbox="example-set" data-title="Optional caption."><img class="example-image" src='<?php echo($array['imagen']);?>' alt=""/></a>
<div class="caption">
<p><?php echo $array['descripcion'];?></p>
<h3><?php echo "$".$array['precio'];?></h3>
<?php echo "<p><a href='descripcion.php?id_plantilla=$array[id_plantilla]' class='btn btn-primary' role='button'>Comprar ahora</a> </p>";?>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</div>
<!--Fin container buscar por tipo-->
</section>
<?php require_once('pie.php'); ?>
</html>
Hi there I'm trying to get a user who comments and is logged in to their account for their 'Login Name' to display when they comment currenlty when a user wants to comment it asks for their name and their comment. Is it possible to display their name getting it from the session to display it? Thanks!
http://puu.sh/cByNU/697e58cdf6.jpg http://puu.sh/cByNU/697e58cdf6.jpg
On the image I'm logged in as 'Testing' is it possible to remove the field 'Name' and when they post a comment it will get their name where the search box is (testing).
Thanks!
My CODE:
<?php
session_start();
include "../includes/config.php";
include "function.php";
include ('../includes/header.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Honda</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='http://fonts.googleapis.com/css?family=Julius+Sans+One' rel='stylesheet' type='text/css'>
<link href="../css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--start lightbox -->
<link rel="stylesheet" type="text/css" href="../css/jquery.lightbox.css">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.lightbox.js"></script>
<script>
// Initiate Lightbox
$(function() {
$('.gallery1 a').lightbox();
});
</script>
</head>
<body>
<!--start header-->
<div class="h_bg">
<div class="wrap">
<div class="wrapper">
<div class="header">
<div class="logo">
<img src="../images/logo.png">
</div>
<div class="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>About</span></li>
<li class="active" class="has-sub"><span>Gallery</span>
</li>
<li class="last"><span>Contact</span></li>
<div class="clear"></div>
<form action="search.php" method="GET">
<div class="search">
<h2>search</h2>
<form>
<input type="text" name="query" placeholder="Enter Your search..." />
<input type="submit" value="">
</form>
</div>
</form>
<div class="search1">
<form action="" method="POST">
<br>
<h2>Welcome, <?=$_SESSION['sess_user'];?>!</h2><br><br>
<div class="pw">
<h3>Change details</h3>
</div>
<br><br>
<h2>Logout</h2>
</form>
</div>
</div>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<!-- start content -->
<div class="content_bg">
<div class="wrap">
<div class="wrapper">
<div class="main">
<div class="ser-main">
<h2 class="style">Gallery of honda</h2>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic1.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic2.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic3.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic4.jpg" alt="">
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<div class="footer_bg">
<div class="wrap">
<div class="wrapper">
<div class="footer">
<div class="search69">
<?php
if(isset($_POST['submit'])
&& !empty($_POST['name'])
&& !empty($_POST['comment']) ){
$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
$insert=mysql_query("INSERT INTO comment (name,comment) VALUES ('$name','$comment') ");
echo "<meta HTTP-EQUIV='REFRESH' content='0; url=service.php'>";
}
else
{
echo "";
}
?>
<form class="comments" action="service.php" method="POST">
<h2>Name: </h2><br><input type="text" name="name" required/><br><br>
<h2>Comment:</h2><textarea name="comment" rows="10" cols="50" required></textarea><br><br><br>
<input type="submit" name="submit" value="Comment">
</form>
<?php
$getquery=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($getquery))
{
$id=$rows['id'];
$date=$rows['date'];
$name=$rows['name'];
$comment=$rows['comment'];
echo '<h2><hr size="1"/><br><font color="green">' . $name . '</font><h2><br/>' . '<br/>' . $comment . '<br/><br><font color="red">' . $date. '</font><br/>' . '<hr size="1"/>'
;}
?>
</div>
<div class="copy">
<p class="w3-link">2014 </p>
Privacy & Policy
</div>
<div class="f_nav">
<ul>
<li>Skype</li>
<li>Linked in</li>
<li>Twitter</li>
<li>Facebook</li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>
(ALL MY CODE ON THAT PAGE)
UPDATE:
The guys here will kill me, because now i am just edited your code, and not rewrite to mysqli or PDO, but as i saw, you stuck, so i've just updated, bacause i do not want to confuse with that too. I do some modifications, check my comments about that. (Moved the block of insertion to the top of file, add an error message, remove unnecesarry variables, rename the rows variable to row, etc...)
<?php
session_start();
include "../includes/config.php";
include "function.php";
include ('../includes/header.php');
//Set an empty errorMsg because later we will check it.
$errorMsg = '';
//If everything is set, or the SESSION["sess_user"] not empty.
//I moved this whole thing here, because if there are no output, we can
//redirect user from PHP, and do not need to use META REFREHS...
if (isset($_POST['submit']) && !empty($_POST['comment']) && (!empty($_POST["name"]) || !empty($_SESSION["sess_user"]))) {
if (!empty($_SESSION["sess_user"])) {
$name = $_SESSION["sess_user"];
} else {
$name = $_POST["name"];
}
//$comment = $_POST['comment']; //Use $_POST["comment"] directly
//$submit = $_POST['submit']; //Do not use it anywhere
$insert = mysql_query("INSERT INTO comment (name,comment) VALUES ('" . mysql_real_escape_string($name) . "','" . mysql_real_escape_string($_POST["comment"]) . "')");
Header("Location: service.php");
} else {
$errorMsg = "You need to fill all the fields.";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Honda</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='http://fonts.googleapis.com/css?family=Julius+Sans+One' rel='stylesheet' type='text/css'>
<link href="../css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--start lightbox -->
<link rel="stylesheet" type="text/css" href="../css/jquery.lightbox.css">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.lightbox.js"></script>
<script>
// Initiate Lightbox
$(function() {
$('.gallery1 a').lightbox();
});
</script>
</head>
<body>
<!--start header-->
<div class="h_bg">
<div class="wrap">
<div class="wrapper">
<div class="header">
<div class="logo">
<img src="../images/logo.png">
</div>
<div class="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>About</span></li>
<li class="active" class="has-sub"><span>Gallery</span>
</li>
<li class="last"><span>Contact</span></li>
<div class="clear"></div>
<form action="search.php" method="GET">
<div class="search">
<h2>search</h2>
<form>
<input type="text" name="query" placeholder="Enter Your search..." />
<input type="submit" value="">
</form>
</div>
</form>
<div class="search1">
<form action="" method="POST">
<br>
<h2>Welcome, <?= $_SESSION['sess_user']; ?>!</h2><br><br>
<div class="pw">
<h3>Change details</h3>
</div>
<br><br>
<h2>Logout</h2>
</form>
</div>
</div>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<!-- start content -->
<div class="content_bg">
<div class="wrap">
<div class="wrapper">
<div class="main">
<div class="ser-main">
<h2 class="style">Gallery of honda</h2>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic1.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic2.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic3.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic4.jpg" alt="">
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<div class="footer_bg">
<div class="wrap">
<div class="wrapper">
<div class="footer">
<div class="search69">
<?php
//Added here the errorMsg
if (!empty($errorMsg)) {
?>
<div class="error"><?php echo $errorMsg; ?></div>
<?php
}
?>
<form class="comments" action="service.php" method="POST">
<?php
if (!empty($_SESSION['sess_user'])) {
//If user logged in, use the name of it
?>
<h2>Name: </h2><br><?php echo $_SESSION['sess_user']; ?>
<br><br>
<?php
} else {
//Else, ask it
?>
<h2>Name: </h2><br><input type="text" name="name" required/><br><br>
<?php
}
?>
<h2>Comment:</h2><textarea name="comment" rows="10" cols="50" required></textarea><br><br><br>
<input type="submit" name="submit" value="Comment">
</form>
<?php
$getquery = mysql_query("SELECT * FROM comment ORDER BY id DESC");
//This is one row, not rows
while ($row = mysql_fetch_assoc($getquery)) {
/*
* These are not necessary
$id = $rows['id'];
$date = $rows['date'];
$name = $rows['name'];
$comment = $rows['comment'];
*/
echo '<h2><hr size="1"/><br><font color="green">' . $row['name'] . '</font><h2><br/>' . '<br/>' . $row['comment'] . '<br/><br><font color="red">' . $row['date'] . '</font><br/>' . '<hr size="1"/>'
;
}
?>
</div>
<div class="copy">
<p class="w3-link">2014 </p>
Privacy & Policy
</div>
<div class="f_nav">
<ul>
<li>Skype</li>
<li>Linked in</li>
<li>Twitter</li>
<li>Facebook</li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>
NOTE: Do not use mysql functions since they are deprecated. use mysqli or PDO functions instead.
Acoid for sql injections, so escape your data!
If i got it well, you want the form to automatically gets the name of a logged user. You should:
<?php $username = isset($_SESSION['sess_user']) ? $_SESSION['sess_user'] : "";?>
To store the username or "" into $username, depending on whether user is authentified or not. Then in your input line within the form:
<h2>Name: </h2><br><input type="text" name="name" value="<?php echo $username; ?>" required/><br><br>
This question already has an answer here:
Parse error: syntax error, unexpected "<" [closed]
(1 answer)
Closed 9 years ago.
I have a code produced by Joomla that displays an error (see title). I debugged it line by line but don't see any problems. Here is the entire code:
<?php
/**
* #copyright Copyright (C) 2008 - 2009 JoomVision.com. All rights reserved.
* #license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
include_once (dirname(__FILE__).DS.'jv_tools.php');
// Javascript
unset($this->_scripts[$this->baseurl . '/media/system/js/mootools.js']);
unset($this->_scripts[$this->baseurl . '/media/system/js/caption.js']);
if($gzip == "true") :
$this->_scripts = array_merge(array($jvTools->templateurl() . 'js/jv.script.js.php' => 'text/javascript'), $this->_scripts);
else:
//$this->_scripts = array_merge(array($jvTools->templateurl() . 'js/jv.collapse.js' => 'text/javascript'), $this->_scripts);
$this->_scripts = array_merge(array($jvTools->templateurl() . 'js/jv.script.js' => 'text/javascript'), $this->_scripts);
$this->_scripts = array_merge(array($jvTools->templateurl() . 'js/mootools.js' => 'text/javascript'), $this->_scripts);
endif;
?>
<!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" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>">
<head>
<jdoc:include type="head" />
<?php JHTML::_('behavior.mootools'); ?>
<link rel="stylesheet" href="<?php echo $jvTools->baseurl() ; ?>templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $jvTools->baseurl() ; ?>templates/system/css/general.css" type="text/css" />
<?php if($gzip == "true") : ?>
<link rel="stylesheet" href="<?php echo $jvTools->templateurl(); ?>css/template.css.php" type="text/css" />
<?php else: ?>
<link rel="stylesheet" href="<?php echo $jvTools->templateurl(); ?>css/default.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $jvTools->templateurl(); ?>css/template.css" type="text/css" />
<link rel="stylesheet" href="<?php echo $jvTools->templateurl(); ?>css/typo.css" type="text/css" />
<?php endif; ?>
<script type="text/javascript">
var baseurl = "<?php echo $jvTools->baseurl() ; ?>";
var jvpathcolor = '<?php echo $jvTools->templateurl(); ?>css/colors/';
var tmplurl = '<?php echo $jvTools->templateurl();?>';
var CurrentFontSize = parseInt('<?php echo $jvTools;?>') // ->getParam('jv_font');?>');
</script>
<!--[if lte IE 6]>
<link rel="stylesheet" href="<?php echo $jvTools->templateurl(); ?>css/ie6.css" type="text/css" />
<script type="text/javascript" src="<?php echo $jvTools->templateurl() ?>js/ie_png.js"></script>
<script type="text/javascript">
window.addEvent ('load', function() {
ie_png.fix('.png');
});
</script>
<![endif]-->
<!--[if lte IE 7]>
<link rel="stylesheet" href="<?php echo $jvTools->templateurl(); ?>/css/ie7.css" type="text/css" />
<![endif]-->
</head>
<body id="bd" class="fs<?php echo $jvTools->getParam('jv_font'); ?> <?php echo $jvTools->getParam('jv_display'); ?> <?php echo $jvTools->getParam('jv_display_style'); ?>">
<div id="jv-wrapper">
<div id="jv-wrapper-inner">
<div id="jv-header" class="clearfix">
<div class="jv-wrapper">
<div id="jv-header-inner">
<div id="jv-logo">
<h1 class="png"><a href="<?php echo $jvTools->baseurl() ; ?>" title="<?php echo $jvTools->sitename() ; ?>">
<span><?php echo $jvTools->sitename() ; ?></span></a>
</h1>
</div>
<div class="jv-wrapper">
<div id="jv-mainmenu" >
<div id="jv-mainmenu-inner">
<?php if($menustyle == 'split' || $menustyle == 'submoo') : ?>
<?php $menu->show(0,0); ?>
<?php else : ?>
<?php $menu->show(); ?>
<?php endif; ?>
</div>
</div>
<?php if($this->countModules('top')) : ?>
<div id="jv-top" >
<jdoc:include type="modules" name="top" />
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php if($this->countModules('slideshow')) : ?>
<div id="jv-userwrap1" class="clearfix">
<div class="jv-wrapper">
<div id="jv-userwrap1-inner">
<jdoc:include type="modules" name="slideshow" />
</div>
</div>
</div>
<?php endif; ?>
<?php
$spotlight = array ('user1','user2','user3','user4');
$consl = $jvTools->calSpotlight($spotlight,$jvTools->isOP()?100:100,'%');
if( $consl) :
?>
<div id="jv-userwrap2" class="clearfix">
<div class="jv-wrapper">
<div id="jv-userwrap2-inner">
<?php if($this->countModules('user1')) : ?>
<div id="jv-user1" class="jv-user jv-box<?php echo $consl['user1']['class']; ?>" style="width: <?php echo $consl['user1']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user1" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user2')) : ?>
<div id="jv-user2" class="jv-user jv-box<?php echo $consl['user2']['class']; ?>" style="width: <?php echo $consl['user2']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user2" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user3')) : ?>
<div id="jv-user3" class="jv-user jv-box<?php echo $consl['user3']['class']; ?>" style="width: <?php echo $consl['user3']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user3" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user4')) : ?>
<div id="jv-user4" class="jv-user jv-box<?php echo $consl['user4']['class']; ?>" style="width: <?php echo $consl['user4']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user4" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<!-- MAINBODY -->
<div id="jv-mainbody" class="clearfix">
<div class="jv-wrapper">
<!-- CONTAINER -->
<div id="jv-container<?php echo $jv_width;?>" class="clearfix">
<div class="jv-mainbody-inner">
<div class="jv-mainbody-top">
<div class="jv-mainbody-bottom">
<div class="jv-mainbody-inset">
<div id="jv-content">
<div id="jv-content-inner">
<?php if($this->countModules('breadcrumb')) : ?>
<div id="jv-pathway" class="clearfix">
<div id="jv-pathway-inner">
<strong><?php echo JText::_('You are here:')?></strong>
<jdoc:include type="modules" name="breadcrumb" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user5')) : ?>
<div id="jv-user5" class="clearfix">
<jdoc:include type="modules" name="user5" style="jvxhtml" />
</div>
<?php endif; ?>
<div id="jv-component" class="clearfix">
<jdoc:include type="message" />
<jdoc:include type="component" />
</div>
<?php if($this->countModules('user6')) : ?>
<div id="jv-user6" class="clearfix">
<jdoc:include type="modules" name="user6" style="jvxhtml" />
</div>
<?php endif; ?>
<?php
$spotlight = array ('col1','col2','col3');
$botsl1 = $jvTools->calSpotlight($spotlight,$jvTools->isOP()?100:99,'%');
if( $botsl1 ) :
?>
<div id="jv-userwrap3" class="clearfix">
<div id="jv-userwrap3-inner">
<div class="jv-spotlight">
<?php if($this->countModules('col1')) : ?>
<div id="jv-col1" class="jv-user jv-box<?php echo $botsl1['col1']['class']; ?>" style="width: <?php echo $botsl1['col1']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="col1" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('col2')) : ?>
<div id="jv-col2" class="jv-user jv-box<?php echo $botsl1['col2']['class']; ?>" style="width: <?php echo $botsl1['col2']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="col2" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('col3')) : ?>
<div id="jv-col3" class="jv-user jv-box<?php echo $botsl1['col3']['class']; ?>" style="width: <?php echo $botsl1['col3']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="col3" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php if($this->countModules('right')) : ?>
<div id="jv-right">
<div id="jv-right-inner">
<jdoc:include type="modules" name="right" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<br class="clearfix"/>
</div>
<br class="clearfix"/>
</div>
</div>
</div>
<!-- END CONTAINER -->
</div>
</div>
</div>
<!-- END MAINBODY -->
<?php
$spotlight = array ('user7','user8','user9','user10');
$botsl2 = $jvTools->calSpotlight($spotlight,$jvTools->isOP()?100:99, '%');
if( $botsl2 ) :
?>
<div id="jv-userwrap5" class="clearfix">
<div class="jv-wrapper">
<div id="jv-userwrap5-inner">
<div class="jv-spotlight">
<?php if($this->countModules('user7')): ?>
<div id="jv-user7" class="jv-user jv-box<?php echo $botsl2['user7']['class']; ?>" style="width:<?php echo $botsl2['user7']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user7" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user8')) : ?>
<div id="jv-user8" class="jv-user jv-box<?php echo $botsl2['user8']['class']; ?>" style="width:<?php echo $botsl2['user8']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user8" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user9')) : ?>
<div id="jv-user9" class="jv-user jv-box<?php echo $botsl2['user9']['class']; ?>" style="width:<?php echo $botsl2['user9']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user9" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user10')) : ?>
<div id="jv-user10" class="jv-user jv-box<?php echo $botsl2['user10']['class']; ?>" style="width:<?php echo $botsl2['user10']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user10" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php
$spotlight = array ('user11','user12','user13','user14');
$botsl3 = $jvTools->calSpotlight ($spotlight,$jvTools->isOP()?100:100,'%');
if( $botsl3 ) :
?>
<div id="jv-userwrap6" class="clearfix">
<div class="jv-wrapper">
<div id="jv-userwrap6-inner">
<?php if($this->countModules('user11')) : ?>
<div id="jv-user11" class="jv-user jv-box<?php echo $botsl3['user11']['class']; ?>" style="width: <?php echo $botsl3['user11']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user11" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user12')) : ?>
<div id="jv-user12" class="jv-user jv-box<?php echo $botsl3['user12']['class']; ?>" style="width: <?php echo $botsl3['user12']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user12" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user13')) : ?>
<div id="jv-user13" class="jv-user jv-box<?php echo $botsl3['user13']['class']; ?>" style="width: <?php echo $botsl3['user13']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user13" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
<?php if($this->countModules('user14')) : ?>
<div id="jv-user14" class="jv-user " style="width: <?php echo $botsl3['user14']['width']; ?>;">
<div class="jv-box-inside">
<jdoc:include type="modules" name="user14" style="jvxhtml" />
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<div id="jv-bottom" class="clearfix">
<div id="jv-bottom-inner">
<div id="jv-userwrap7" class="clearfix">
<div class="jv-wrapper">
<div id="jv-userwrap7-inner">
<div id="jv-footer">
<div id="jv-footer-inner"><jdoc:include type="modules" name="footer" /></div>
</div>
<div id="jv-copyright">
<div id="jv-copyright-inner">
Copyright © 2008 - <?php echo date(Y); ?> <a title="Gashon" href="http://www.omrestaurant.ca">Powered</a> by GASHON. All rights reserved.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<jdoc:include type="modules" name="debug" />
</body>
</html>
Here are a few observations:
in Safari I get a malware warning saying the site may harm my computer, but in IE8 it's fine
the path to the code above is /home/content/93/7079893/html/om/templates/jv_cera/index.php, but the path the website displays when it gives me the error is /home/content/93/7079893/html/om/index.php, as in "Parse error: syntax error, unexpected '<' in /home/content/93/7079893/html/om/index.php on line 105". Could it be that the error is referring to another website?
Line 105 is the last div in this block of code:
<?php if($this->countModules('slideshow')) : ?>
<div id="jv-userwrap1" class="clearfix">
<div class="jv-wrapper">
<div id="jv-userwrap1-inner">
<jdoc:include type="modules" name="slideshow" />
</div>
</div>
</div> // <<-- THIS IS LINE 105
<?php endif; ?>
Can someone please help? Thank you kindly.
If you'd like to check whether the error is referring to another website, add a few pointless HTML lines (like ") ABOVE line 105, then run again. If the error is coming from this page, it the line number should be greater than 105.
Dumb point, but I'm going to mention it anyway: if the error is client side instead of server side, look at the source code that makes it to your browser, not this PHP code.