Auto-sizing google adsense code on php site - php

I have a php site. I have been given code for an auto-sizing ad from google adsense. I have put this within a "div" to align it, and have created a function to echo the adsense code within my php script;
<html>
<head>
<title>MY WEBSITE</title>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<body>
<?php include("title.php"); ?>
<?php
$googleadsensecode = ' //a function for the adsense code.
<div align="center"> //<div> to align the ad.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Responsive_TextnDisplay_20160127 -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-9232383262111727"
data-ad-slot="4287484293"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>';
echo $googeladsensecode;
</body>
</html>
However the ad is taking up the whole page, and thus is presumably not picking up on the remaining website's content.
What is the error in my code or my approach?

Related

Html and Php image not showing online but showing in localhost

The file location of the image is correct and it displays on localhost however doesn't online, how would i be able to get this to work?
I have tried changing the images from png to jpg and using different images and changing the file locations and then updating that on the code however it still does not display the image
<!DOCTYPE HTML>
<html>
<head>
<title>KMS</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="UTF-8">
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript" src="http://s.sharethis.com/loader.js"></script>
</head>
<body id="wrapper">
<div id="header">
<!--Logo-->
<div id="Logo">
</div>
<!--Logo-->
<!--Menu Buttons-->
<?php include 'menu.php';?>
<!--Menu Buttons-->
</div>
<div id="hContent">
<!--Frames--====================================================================-->
<div id="hFrames">
<!--Information go below-->
<div id="infoCon1">
<img id="kms_img" src="Images/Kmsproductsinformation.jpg" style="width:850px;"/>
<b />
<b />
</div>
<!--Information end-->
</div>
</div>
</div>
<!--
footer
-->
</body>
</html>
Try <img id="kms_img" src="images/kmsproductsinformation.jpg" style="width:850px;"/> and ensure that your images directory and kmsproductsinformation.jpg file are in lowercase.
You've got something funny going on with your DIVS. You have what looks like two additional close DIV tags () towards the end of your file - I'd start by fixing those up.
Having said that it also shouldn't really matter if it's localhost or not, or whether it's jpg or png but PNG would be better if you're setting it to a non-100% width.
Try something basic without all the DIVS or your menu.php file and see if that works.
<!DOCTYPE HTML>
<html>
<head>
<title>KMS</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="UTF-8">
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript" src="http://s.sharethis.com/loader.js"></script>
</head>
<body id="wrapper">
<img id="kms_img" src="Images/Kmsproductsinformation.jpg" />
</body>
</html>

Map Geolocation not working/ no display appearing

this is my first post and currently in a dire situation for a web development assignment, which requires us to create a php based website which allows the user to search for wifi locations with the use of google maps API. However when I run the code all i get is a blank map and no errors.
Help is much appreciated.
thanks
<!DOCTYPE html>
<!-- HTML5 doctype-->
<html>
<!-- Start of html document-->
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 25 March 2009), see www.w3.org"><!-- Header which calls the relevant stylesheets for display. It also outlines the page title and initial scale. -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta>
<title>Reece & Andy INB271 Website</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" media="only screen and (max-width: 480px), only screen and (max-device-width: 480px)" href="small-device.css">
<link rel="stylesheet" type="text/css" media="only screen and (max-width: 700px), only screen and (max-device-width: 700px)" href="med-device.css">
<link rel="stylesheet" type="text/css" media="only screen and (max-width: 980px), only screen and (max-device-width: 980px)" href="large-device.css">
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">
</script>
<script type="text/javascript">
<!-- source for the google maps api script-->
function getLocation()
{
var x=document.getElementById("usercoords");
if (navigator.geolocation)
{
//runs showposition function
navigator.geolocation.getCurrentPosition(showPosition);
}
else
{
x.innerHTML="Geolocation not supported.";
}
}
function showPosition(position)
{
var x=document.getElementById("usercoords");
//adds coordinates to html at id "usercoords"
x.value=position.coords.latitude + "," + position.coords.longitude;
document.getElementById("search").submit();
}
function initialize()
{
var mapOptions =
{
zoom: 10,
center: new google.maps.LatLng(-27.4699404325,153.02562796)
}
var map = new google.maps.Map(document.getElementById('map-search'), mapOptions);
//sets markers
setMarkers(map, hotspots);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<!-- Body of the website containing the wrapper, nav, search and content divs. -->
<body>
<div id="wrap"><!-- The wrapper for the whole website -->
<?php include 'header.php'; ?>
<div id="content">
<h1>Location Search</h1>
<p id="Click">Click the button to get your position:</p>
<button onclick="getLocation()">View Location</button> <!-- when clicked, returns geo location marker on map -->
<br>
<div id="Breaker"><!-- Textbox field for the Hotspot name -->
<p><label>Hotspot Name:</label> <input type="text" name="name"></p>
<!-- Number input for the rating with a minimum of 1 and maximum of 5 (i.e. rating can't be 6 or 0) !-->
<p><label>Hotspot Rating:</label> <input type="number" name="rating"></p>
<!-- Radio button input that uses geolocation (if yes is selected and access is granted) to retrieve the user's current location !-->
<p><label>Nearby Playgrounds:</label> <input id="r-yes" type="radio" name="geo" value="yes" onclick="getLocation()"><label for="r-yes" onclick="getLocation()">Yes</label> <input id="r-no" type="radio" name="geo" value="no" checked="true"><label for="r-no">No</label></p>
<h4>Search By Suburb</h4>
<!-- <!== search using the form-->
<form id="form3"><!-- fields and styling for the dropdown -->
<select name="Suburb">
<option value="West End, 4101">West End</option>
<option value="Wynnum, 4178">Wynnum</option>
<option value="Zillmere, 4034">Zillmere</option>
<!-- search box-->
<!-- Onclick RETURNS RESULTS !-->
<!-- closes the article --></select></form>
<!-- closes the form --></div>
</div>
<!-- This is the page right sidebar and includes linkes to nearby hotspots and recent hot spot reviews. -->
<?php include 'sidebar.php'; ?><!-- This is the footer for the website. It includes our student numbers, names and the council logo. -->
<?php include 'footer.php'; ?></div>
</body>
</html>
Try with this google map's js.You're using this,
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">
Instead of try with following,
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE&sensor=false">
</script>

MPDF PDF formatting

I am trying to convert a complete webpage as-is to PDF as part of my final year university project, and have found MPDF extremely useful for this task, however I'm struggling a little with the presentation of the actual output.
The page itself looks like below:
and I would like it to be presented exactly as it is above when converted to PDF, however converting seems to remove all styles from the document, presenting it like so:
The code I have used to convert the page is below:
<?php
ob_start();
include("checklog.php");
require_once("watchlist-controller.php");
?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="img/fav.ico">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<title>Screening - Your ticket to your movies - <?php echo $watchlist_name; ?></title>
<meta name="description" content="Screening is a brand new take on the traditional movie database, fusing social networking and multimedia to provide a clear, concise experience allowing you to share your favourite movies, and discover new classics.">
<meta name="keywords" content="Movies, Films, Screening, Discover, Watch, Share, experience, database, movie database, film database, share film, share films, discover film, discover films, share movie, share movies, discover movie, discover movies">
<!-- Bootstrap -->
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/custom-bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="fonts.css" type="text/css" />
<link rel="stylesheet/less" type="text/css" href="css/stylesheet.less" />
<script src="js/less-1.3.3.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Start Google Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- End Google Analytics -->
</head>
<body>
<div class="container"><?php
require_once ("header.php");?>
<div id="main" class="well main-content">
<p class="page-title"><?php echo $watchlist_name; ?></p>
<div class="row-fluid">
<section class="span12 watchlist-holder film-list"><?php
if (count($films) == 0) {?>
<div class="alert alert-info">This Watchlist is empty! Why not visit a movie page to add something to it?</div><?php
} else {?>
<ul class="unstyled"><?php
foreach($films as $key => $film_item) {
include("watchlist-film-controller.php");?>
<li class="well list-item clearfix">
<div class="row-fluid">
<img src="<?php echo $poster_thumb; ?>" alt="<?php echo $title; ?> poster" title="<?php echo $title; ?> poster" />
<div class="span11 movie-info">
<p class="search-title"><?php echo $title; ?> <small>(<?php echo $year; ?>)</small></p><?php
if ($critics_consensus == "") {?>
<p class="watchlist-synopsis">No overview available</p><?php
} else {?>
<p class="watchlist-synopsis"><?php echo $critics_consensus; ?></p><?php
}?>
</div>
</div>
</li><?php
}?>
</ul><?php
}?>
</section>
</div>
</div><?php
include 'footer.html'; ?>
</div>
</body>
</html><?php
$HTMLoutput = ob_get_contents();
ob_end_clean();
//Convert HTML 2 PDF by using MPDF PHP library
include ("mpdf/mpdf.php");
$mpdf=new mPDF();
$mpdf->WriteHTML($HTMLoutput);
$mpdf->Output();?>
I'm not the most experienced of PHP coders, and I'm still learning much as I go along, so any pointers would be appreciated. I'm not sure if the way I've attempted to convert using MPDF is the best way to approach the problem, either, which may be an issue.

Insert stylesheet into iframe

I opened this thread because I tried a lots of methodes I found here or elswhere to insert my custom stylesheet into an iframe with jQuery but none of them worked.
And now I'm stuck.
I'm open for any suggestion, for me it's not necessary to do it with jQuery if there is any other souliton.
this is what I have now:
<!doctype html>
<html lang="hu">
<head>
<meta charset="utf-8">
<title><?php echo $this->title; ?></title>
<link rel="stylesheet" type="text/css" href="css/style.css" media="all" />
<script src="//ajax.googleapis.com/ajax/libs/mootools/1.4.5/mootools-yui-compressed.js"></script>
<script src="js/mootools-more.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#iwiw').load(function(){
$('#iwiw').contents().find('head').append('<link href="css/iwiw.css" rel="stylesheet" type="text/css" />');
});
});
</script>
</head>
<body>
<header><!-- content --></header>
<div id="container">
<div id="left">
<iframe id="iwiw" src="http://iwiw.hu/like.jsp?u=<?php echo $url; ?>&title=<?php echo str_replace('+', '%20', urlencode($this->title)); ?>&t=tetszik&s=white" width="220px" height="120px" style="border: none;" scrolling="no" frameBorder="0"></iframe>
</div>
<div id="right"><!-- content --></div>
</div>
<footer><!-- content --></footer>
</body>
in the code $url is the current url encoded with urlencode and $this->title is the current page title and as you can see my document type is html5 and what you don't see is that the iframe's SRC is XHTML transitional.
Actually the iframe is the original working code if you would like to test it, just replace $url with your site's url and the $this->title with your site's title.
You cannot do that unless the current page is also from iwiw.hu. There is a cross-domain limitation, you cannot touch the output inside the <iframe> you created if it's outside your domain.
Some answers here ... unless the iframe domain defers from the main page.
How to apply CSS to iframe?

Why would javascript not work when the page is fully rendered but works when I get fatal PHP errors?

I've been attempting to use jquery and jqueryui to make tabs on my website. However, I can't seem to get them to work. The main page is in PHP, and I am using the Codeigniter framework. If the page fully renders, then the tabs won't work. If I change something that creates a fatal error in the php the tabs appear. While I was attempting to figure out what was going on I created a very basic page with only the jquery demo script, and it wouldn't work either. If it makes any difference, I am hosting on HostGator.
Please advise.
Header:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Sign Up!</title>
<link rel="stylesheet" href="<?php echo base_url();?>css/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo base_url();?>css/jquery-ui-1.8.11.custom.css" type="text/css" media="screen" />
<!-- Java includes -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js" type="text/javascript"></script>
</head>
<body>
<div class = "header">
<span class="nav_bar"><?php if($this->session->userdata('is_logged_in')){ echo 'Welcome, ' . ucfirst($this->session->userdata('first_name')). " " . ucfirst($this->session->userdata('last_name')) . ' | ' . anchor('site/logout' , 'Logout');} else { echo anchor('site/is_logged_in', 'Login');} ?></span>
</div>
<div class="content">
Body:
<!-- Tab Script -->
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
<!-- end Tab Script -->
<div id="tabs">
<ul>
<li>All Contacts</li>
<li>Place Holder Tab</li>
</ul>
<div id="tabs-1">
<?php $this->load->view('all_contacts_tab_view'); ?>
</div>
<div id="tabs-2">
Place Holder tab
</div>
</div>
Footer:
</div> <!-- end content div -->
<div class="footer">
<div class="footer_left">
<div id="copyright"> © 2011 NetworkIgniter. All rights reserved. NetworkIgniter, networkigniter.com and the all designs are trademarks of NetworkIgniter. Created with CodeIgniter and hosted on HostGator.</div>
<div id="legal">Terms and Conditions | Privacy Policy</div>
<div id="benchmarking">{elapsed_time} | {memory_usage}</div>
</div>
</div>
</body>
</html>
I did track down a java error after all, but I'm not sure how to fix it.
Error: $("#tabs").tabs is not a function
Line: 23
it looks like your calling tabs before it generated I would put that in doc ready
$(document).ready(function() {
$( "#tabs" ).tabs();
});
Figured it out.
It was the Google tracking script at the end. It was claiming the $. the reason why it was working when php crashed was because it wasn't getting down to the footer where the Google script was.
Errors on tabs are often due to a missing end of tag such as a </div> or </li> or whatever. Check the code generated by the PHP script to see if everything's fine. You might wanna use the Developper Tools Plugin on FireFox to detect any validation problems (including the missing tags).

Categories