page on selected articles not displaying content - php

I have my website LOCATED HERE.
If you click on "FREE" on the home page then click one of the logos for the 2 offers to be diverted to the /single.php?id= page, You can see that the logo and text are displayed.
However MY PROBLEM IS: if you click on "GIFT" from the home page you can see the logo and description but then clicking on the logo it brings up the /single.php?id= page once again but it has a problem loading.
my code for single.php is:
<?php
include_once('include/connection.php');
include_once('include/article.php');
$article = new storearticle;
if(isset($_GET['id'])) {
$id = $_GET['id'];
$data = $article->fetch_data($id);
?>
<html>
<head>
<title>Xclo Mobi</title>
<link rel="stylesheet" href="other.css" />
</head>
<body>
<?php include_once('header.php'); ?>
<div class="container">
Title Page<br /><br />
<div align="center">
<img src="<?php echo $data['promo_image']; ?>" class="img"><br />
<font class="title"><?php echo $data['promo_title']; ?></font>
<p>
<?php echo $data['promo_content']; ?>
<img alt="" title="" src="GO.png" height="50" width="50" align="right" />
<br /><br /></div>
<b><u>More From This Brand</b></u>
<br /><br />
← Home
</div>
<?php include_once('footer.php'); ?>
</body>
</html>
<?php
} else {
header('location: index.php');
exit();
}
?>
can someone please tell me where I am going wrong because I have been trying to fix this for days.
If you need any more information from me then please ask. thank you.

Related

php file is working on local server but fails when on online server

I did complete a website for online Entrance form for students as my demo project to learn. When I run from my local server it works fine but when I uploaded on webserver and tasted index.php and other files run fine except when user enter his/her symbol no to check if he/she already been registered or not..I have coded a logic
if (exists)>Show admit card
if(don't exist)>show alert box
It works fine in local server but in webserver when I enter value in search box and enter then it shows empty page with no any error.
I have one row in my database. So in case you wanna check here is the symbol no in column =15369-2017-02 . On Entering submit it should show admit card and you can enter any random value other then this .which should show alert box.
Here is my website
https://cmprc.edu.np/condensed/entrance_form_demo/studntreport/main/
This is the code of file which is not responding and showing blank
<html>
<head>
<title>
CDP || Admission Form
</title>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="../style.css" media="screen" rel="stylesheet" type="text/css" />
<body style="background-color: white;">
<?php
include('../connect.php');
$var_value = $_POST['search_value'];
echo $var_value;
$sql="SELECT * FROM entrance WHERE re_value='$var_value'";
$STH = $db->prepare($sql);
$STH->execute(array($var_value));
$User = $STH->fetch();
if (empty($User))
echo "<script>alert('Sorry, you Have not Registered yet');
window.location = 'index.php';</script>";
else
$result = $db->prepare("SELECT * FROM entrance
WHERE re_value = '$var_value' ORDER BY id ASC;");
$result->execute();
for($i=0; $row = $result->fetch(); ){
?>
<link href="../style.css" media="screen" rel="stylesheet" type="text/css" />
<center><h4><i class="icon-edit icon-large"></i> You've Already Registered</h4></center>
<hr>
<center>
<div class="panel panel-default">
<div class="container">
<div class="row">
<div class="col-md-4 seventy">
<img src="img/admit.png"/ >
</div>
<div class="col-md-8 thirty">
<img src="../image/profile/<?php echo $row['pic_value'];?>" class="roundimage2" alt=""/>
</div>
</div>
</div>
<hr>
<table style=" width: 500px;">
<tr>
<td >Roll no: </td>
<td> <?php echo $row['id']; ?></td>
</tr>
<tr>
<td >Name : </td>
<td > <?php echo $row['name_en_value']; ?></td>
<td > Subject: </td>
<td > <?php echo $row['ge_value']; ?> </td>
</tr>
</table>
<br><br>
<h5><i><strong>STUDENTS MUST BRING THIS ADMIT CARD ON THE DAY OF EXAMINATION</strong></i></h5>
<br>
</div>
</center>
<?php
}
?>
</body>
<?php include('footer.php');?>
</html>
Any help? I did almost finished it which I was working continously for 4-5 Days.
It seems that your php is not executed correctly. Maybe try to enable error reporting to get a hint of what's wrong.
Include the following at the beginning of your destination file (my.php)
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);

How to echo value from php to html

how do i echo a value from php to html in a division (div2--a div i created) of a paragraph(p).
for example: i have a value called $greetings and i assign a value of "Welcome" to it
$greetings = "Welcome";
I tried:
`<p>
<?php
$index = "WELCOME";
echo "<div2>$index</div2>";
?>
</p>`
but it doesn't display the value of $greetings--welcome
instead it displays ( $index"; ?> )
HERES MY ENTIRE CODE:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Tech Planet</title>
<link rel="stylesheet" type="text/css" href="style.css">
<img src="logo.gif" alt="logo" width="150" height="50">
<div class ='seachAndProducts'><form action="header.php" method="GET">
<input id="search" type="text" placeholder="Search Tech Planet...">
<input id="submit" type="submit" value="Search">
</form></div>
<div class = 'navAndFooter'><ul>
<li><b>Home</b></li>
<li><b>Products</b></li>
<li><b>About</b></li>
<li><b>Contact us</b></li>
</ul></div>
<img src="cart.jpg" alt="cart" width="40" height="40">
</head>
<body>
<h3><img src="WelcometoTechPlanet.gif" width="250" height="40"></h3>
<h5><div class ='ourAndFeatProductsHeader'>Our Products</div>
<div class='seachAndProducts'>
<div class='ourProductsList'>Audio Systems</div>
<div class='ourProductsList'>Cameras</div>
<div class='ourProductsList'>Laptops</div>
<div class='ourProductsList'>Memory Cards</div>
<div class='ourProductsList'>Monitors</div>
<div class='ourProductsList'>Phones</div>
<div class='ourProductsList'>Televisions</div>
<div class='ourProductsList'>USBs</div>
<div class='ourProductsList'>All Products</div>
</div><div class ='ourAndFeatProductsHeader'>Featured Products</div>
<div2><img src="8wb50.gif" alt="" width="250" height="200"></div2></h5>
<p><?php
$index = "WELCOME";
echo "<h1>$index</h1>";
?></p>
<!-- used &copy because © displays © -->
<div class = 'navAndFooter'>&copy Tech Planet. All Rights Reserved.</div>
</body>
</html>
Here are a few things to note...
Don't put an h1 tag in the p tag; and you are echoing $index, not $greetings.
Try this
<?php
// Pick the one you want.
$greetings = "Welcome";
$index = "WELCOME";
// Pick the one you want
echo "<h1>$index</h1>";
echo "<h1>$greetings</h1>";
?>
Then, make sure you save it as a .php file, and that you are on a web server with php enabled.

Database link not working

I have a problem with this page
the green go logo next to the image is meant to visit the promotions site saved on my database. But it loads the same page in a new tab.
My code for this is:
<img alt="" title="" src="GO.png" height="50" width="50" align="right" />
Any ideas why it does not work?
If you need any code for any of my pages then please let me know and I will edit this and add it.
Thanks.
HOW DO I HREF MY GO IMAGE TO A LINK SAVED UNDER promo_link IN MY DATABASE TABLE?
<?php
include_once('include/connection.php');
include_once('include/article.php');
$article = new article;
**if(isset($_GET['id'])) {
$id = $_GET['id'];
$data = $article->fetch_data($id);**
$articles = $article->fetch_all();
?>
<html>
<head>
<title>xclo mobi</title>
<link rel="stylesheet" href="other.css" />
</head>
<body>
<?php include_once('header.php'); ?>
<div class="container">
Category = ???
<?php foreach ($articles as $article) {
if ($article['promo_cat'] === $_GET['id']) { ?>
<div class="border">
<a href="single.php?id=<?php echo $article['promo_title']; ?>" style="text-decoration: none">
<img src="<?php echo $article['promo_image']; ?>" border="0" class="img" align="left"><br />
**<img alt="" title="" src="GO.png" height="50" width="50" align="right" />**
<br /><br /><br /><br />
<font class="title"><em><center><?php echo $article['promo_title']; ?></center></em></font>
<br /><br />
<font class="content"><em><center><?php echo $article['promo_content']; ?></center></em></font>
</div><br/><br />
</a>
<?php } } } ?>
</div>
<?php include_once('footer.php'); ?>
</body>
</html>
Your href attribute is empty and because you're using target="_blank" clicking on the link will open the same page in a different tab.
The $data['promo_link'] is empty. I can't tell why because there is no code.
Edit
It seems you forgot the brackets
replace $article = new article; with $article = new article();
also $article->fetch_data($id) is probably returning an empty value.
As I can see, your id value is "FREE". make sure that article->fetch_data("FREE") returns what you expecting it to return.
I also suggest changing you code style.
This is much more easy to read:
if ($param){
echo '<div>' . $data["bla"] . '</div>';
}
mixing your PHP code and yout HTML code makes it hard to read and understand.
Note: <font class="title"><em><center><?php echo $article['promo_title']; ?></center></em></font> is deprecated. Use CSS:
HTML/PHP code:
echo '<div class="title">' . $article['promo_title'] . '</div>';
And the CSS:
.title{
text-align: center;
font-size: 1.5em;
}

correct place for my form tag to pass correct value in action PROBLEM

i have this code:
<body>
<div class="header">
<?php if (isset($_SESSION['user_id']) && !isset($menu)) { ?>
<div class="menu_holder">
<ul>
<li>
<a href="<?php echo ADDRESS; ?>menu.php" class="green_link">
<img src="<?php echo IMAGES; ?>template/menu.gif" width="51" height="20" border="0" />
</a>
</li>
</ul>
</div>
<?php } ?>
<?php
if (!isset($plainHeader))
{
$plainHeader = " ";
?>
<img src="<?php echo IMAGES; ?>template/logo.gif" width="160" height="94" />
<?php
}
?>
</div>
<br/>
<?php $id_to = $user['profile_id_contact']; ?>
<div class="main_content">
<center>
<div class="innerContainer">
<span class="headings2">FREE CHAT CONTACTS</span>
<form id="message_area" style="display:none" method="post" action="<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to ?>">
<?php
if (count($users) > 0)
{
foreach ($users as $user)
{
//some php here
?>
<a href="#" class="charcoal_link" style="line-height: 20px;" onclick="showMessageArea(this); return false;" >
<?php echo $uniqueCode1?><span class="pink_text"><?php echo $uniqueCode2?></span><?php echo $uniqueCode3?>
</a>
<textarea name="message" rows="10" cols="20"></textarea>
<input name="Submit" type="submit" value="Send"></input>
<?php
}
}
?>
</form>
</div>
</center>
</div>
</body>
as my code is now the form tag is in the wrong place because my tag links does not show.
where must i put my form tag so that when i click on any of the uniquecode links i pass the correct $id_to in the action??? when i move the form tag after the my links show but regardless of which link i click on it passes the first link's $id_to with the action. i have also tried to pass $id_to as a hidden field which i had after the sumbit but still it passes the first link's id
please help? i have been struggeling with this for some time now...i cannot redirect the page via JS becuase this site is for a MOBILE aka mobi site
please help? im desperate
thank you
if i move the form tag and have it like this:
messageSent.php?id=">
and i view the page source $id_to contains correct id but as sson as i go to sentMessage.php the id in the url is incorrect
To pass a id to the next page in a link you need to add "?id='.$id.'" at the end of the url.
e.g.
<a href="<?php echo ADDRESS; ?>menu.php?id=5" class="charcoal_link" style="line-height: 20px;">
To make sure that each link is different you can right click and copy the url to double check.

PHP & WP: Render Certain Markup Based on True False Condition

So, I'm working on a site where on the top of certain pages I'd like to display a static graphic and on some pages I would like to display an scrolling banner.
So far I set up the condition as follows:
<?php
$regBanner = true;
$regBannerURL = get_bloginfo('stylesheet_directory'); //grabbing WP site URL
?>
and in my markup:
<div id="banner">
<?php
if ($regBanner) {
echo "<img src='" . $regBannerURL . "/style/images/main_site/home_page/mock_banner.jpg' />";
}
else {
echo 'Slider!';
}
?>
</div><!-- end banner -->
In my else statement, where I'm echoing 'Slider!' I would like to output the markup for my slider:
<div id="slider">
<img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/1.jpg" alt="" />
<img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/2.jpg" alt="" />
<img src="<?php bloginfo('stylesheet_directory') ?>/style/images/main_site/banners/services_banners/3.jpg" alt="" />
.............
</div>
My question is how can I throw the div and all those images into my else echo statement? I'm having trouble escaping the quotes and my slider markup isn't rendering.
<div id="banner">
<?php if($regbanner): ?>
<img src="<?php echo $regBannerURL; ?>/style/images/main_site/home_page/mock_banner.jpg" />
<?php else: ?>
<div id="slider">
<img src="<?php echo ($bannerDir = bloginfo('stylesheet_directory') . '/style/images/main_site/banners/services_banners'); ?>/1.jpg" alt="" />
<img src="<?php echo $bannerDir; ?>/2.jpg" alt="" />
<img src="<?php echo $bannerDir; ?>/3.jpg" alt="" />
.............
</div>
<?php endif; ?>
</div><!-- end banner -->
If you don't like the offered solution using the syntaxif(...):...else...endif; you also have the possibilty of using heredoc-style to include bigger html-parts into an echo-statement without the need of escaping it.
The code-formatting in here unfortunatly messed up my example, which I wanted to post. But if you know the heredoc-notation, it should not be a problem ;)

Categories