This is my first PHP-based web project. I have the web part of it working perfectly, but I'm having trouble with the mobile version. (Web hosting on godaddy linux)
What is the reason for my .php page not displaying? If I change it to .html, it works fine.
(I suspect the doctype, but not sure.)
Not sure if this code is necessary, but I'll leave out the body for the sake of space:
<?php include_once 'web/config.php'?>
<!DOCTYPE HTML>
<html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>About - Mobile</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">
<meta name="keywords" content="About - Mobile" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
</head>
config.php:
$link = mysqli_connect($server, $db_user, $db_pass);
mysqli_select_db($link, $database);
// -=-=-=-=-=-=-=[ Getting Variables ]=-=-=-=-=-=-=- //
$query = "SELECT * FROM `misc`";
$result = $link->query($query);
while($info = mysqli_fetch_array($result)){
// -=-=-=-=-=-=-=[ Variables ]=-=-=-=-=-=-=- //
$pickupTime = $info['pickupTime'];
$deliveryTime = $info['deliveryTime'];
$minDeliveryPrice = $info['minDeliveryPrice'];
$Gtitle = $info['Gtitle'];
$emailAccount = $info['emailAccount'];
$phone = $info['phone'];
$mailSubject= $info['mailSubject'];
$address = $info['address'];
$city = $info['city'];
$zipcode = $info['zipcode'];
$companyTel = $info['companyTel'];
$companyEmail = $info["companyEmail"];
$facebookLink = $info['facebookLink'];
$twitterLink = $info['twitterLink'];
$googleLink = $info['googleLink'];
$termsOfService = $info['termsOfService'];
}
?>
Thanks in advance!
PHP is executed at server side, as long as the PHP script renders valid HTML (this however doesn't seem the case), the phones won't care.
In case PHP code is received by a browser, something is wrong with the sever (for instance you didn't install PHP at server side, or the webserver doesn't know when to call PHP to generate a webpage)
A browser never receives the PHP code (otherwise it would be easy for instance to hijack databases since the PHP code has somehow the password).
PHP executes on the server, the client doesn't know it is talking to PHP. You need not change PHP code when targeting mobile platforms.
Your issue appears to be corrupt HTML
<?php include_once 'web/config.php'?>
We should probably see the config.php file to see what is happening in there.
<!DOCTYPE HTML>
<html>
Here you open an <HTML> tag.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
Here you open another <HTML> tag, this is an issue. You should only have one <HTML> tag as your outer node in the document.
<head>
<title>About - Mobile</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">
<meta name="keywords" content="About - Mobile" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
</head>
You do not close your <HTML> tags and you do not have a body to render.
Well since you said you posted only the head. Im just gonna fix your html to at least make it valid. And regarding the php, other answers explain why php doesn't matter when viewing websites in browsers
<?php include_once 'web/config.php'?>
<!DOCTYPE HTML>
<html>
<head>
<title>About - Mobile</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">
<meta name="keywords" content="About - Mobile" />
<link href="css/style.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
....
</body>
</html>
If this doesn't work, then I am guessing that this line of php <?php include_once 'web/config.php'?> is outputting something which is messing up the html or in other words, make it invalid, so try removing it and then tryAlso what do you mean its not displaying? Like nothing shows up? Or does it give an (http and or php) error?
Related
Here is the title and link I used with the header, but I just get the word "Document" instead
<title>Chicken and Waffle | Local 360 | Gunyen</title>
<link rel="shortcut icon" type="image/png" href="images/gunyen%20logo%20dark.png">;
sample: https://gunyen.com/post/local360chknnwfl.php
What am I doing wrong?
Check your code again! This is the page source code I see in my browser:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="docsearch:language" content="en">
<meta name="docsearch:version" content="4.3">
<meta content="width=device-width, initial-scale=1" name="viewport">
<link rel="shortcut icon" type="image/png" href="images/gunyen%20logo%20dark.png"/>
<!--https://developers.google.com/search/reference/robots_meta_tag#directives-->
<!--<meta name="robots" content="index, follow, archive">-->
<meta name="robots" content="nofollow, noindex">
...
As you can see, there are 2 head blocks!
Most browsers will pick up favicon.ico from the root directory of the site without needing to be told; but they don't always update it with a new one right away.
However is a correct way to achieve your task with the name of favicon.ico:
<link rel='shortcut icon' type='image/x-icon' href='images/gunyen/logo/favicon.ico' />
Reference: https://stackoverflow.com/a/9943834/6366593
I have a site build on WordPress. Everything looks perfect on all devices. I've tested against Chrome, Firefox, Safari, IE8+, Android, etc. No problems.
The client pulls up the site on their machine and phone and it stripped of everything in the header and footer that loads via php (header.php and footer.php). Shortcodes load the content as expected. but there's no page styling.
I tested again even had outside users test on phones (and even a Chromebook on a Starbucks wifi), looks fine.
I had the client clear cache, nothing. His machine is on a company network but his phone isn't but they both have the same issue.
I have a staging and production site, both have the same result.
----- Edit -----
The head in header.php is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="w3.org/1999/xhtml"; dir="ltr" <?php language_attributes(); ?>>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
</head>
The client's page source shows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
notice that the wp_head(); didn't output the CSS. profile, pingback, and viewport didn't render either.
I've added the code
<meta name="viewport" content="width=device-width, initial-scale=1" />
to the HEAD of my webpage the Index.php at DuchyBrass.co.uk
It is on Line 6 of the source code, but the site runs on a bespoke CMS so the HEAD is defined in its own file and imported.
index.php
<!DOCTYPE html>
<html lang='en'>
<head>
<?php include 'app/common/head.php'; ?>
</head>
<body>
...
head.php
<title>Duchy Brass</title>
<meta charset="windows-1252" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="google-site-verification" content="QsU348JA47VLcAbTUic-Un90bVlGuVk3a9A34doxsvc" />
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href='http://fonts.googleapis.com/css?family=Viga' rel='stylesheet' type='text/css'>
<link rel="icon" type="image/png" href="imgs/favicon.ico">
<link rel="canonical" href="http://www.duchybrass.co.uk" />
As far as the browser is concerned (I assume) that viewport tag is visible, but it is not seen by that Mobile SEO tool. Is this something to do with the CMS, loading the information too late, or is this a common issue that I should ignore?
The top of my Index page (using view page source from the browser) looks like
/ (page source)
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Duchy Brass</title>
<meta charset="windows-1252" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
...
TL;DR: clear caches and check if there is no content before head (ctrl+U)
I had a similar problem, in my case there were content being included trough PHP before my wordpress header call,
check it with Ctrl+U (see source) and be sure there is nothing before the
<!DOCTYPE html>
<html lang='en'>
<head>
if you change the code and it persists, check if you're using cache, you may have to clear caches of pages and files so the changes take effect before running another PageSpeed analysis
I have a website that uses a global header.inc file, containing the header I want on top of every HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="de-at" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="standard.css.php" />
...etc...
Hence, the pages themselves look like this:
<?php include "header.inc"; ?>
<title>Page Title</title>
<style type="text/css">
/* additional style sheets for only this page */
</style>
</head>
<body>
...
Obviously, Expression Web complains about the unopened </head> tag and ignores the stuff present in the header file (e.g., the stylesheet), which makes the preview pane rather useless.
Since EW4 is supposed to "work nicely" with PHP, is there some way to make the preview pane honor includes? I've told EW where it can find the php-cgi.exe, so in the browser preview everything works nicely.
I wrote a small MVC app for a small website I am working on. I created a load method that loads the header, footer, and the specified view file. I am having issues to where the header is not loading all of the JS files and the entire document's HTML structure is missing indents.
Header.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo $meta['title']; ?></title>
<?php //load all of the css files
foreach (glob("layout/css/*.css") as $css_filename)
{
echo '<link rel="stylesheet" href="'.INSTALL_PATH.'/'.$css_filename.'">';
}
//load all of the js files
foreach (glob("layout/js/*.js") as $js_filename)
{
echo '<script src="'.INSTALL_PATH.'/'.$js_filename.'"></script>';
}
?>
</head>
<body>
Renders as:
<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Test Title</title>
<link rel=stylesheet href="/labs/wpsm/layout/css/style.css"><script></script></head>
<body>
One weird thing that I discovered is that if I include random text before the doctype declaration, everything is back to normal.
With extra character:
s
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test Title</title>
<link rel="stylesheet" href="/labs/wpsm/layout/css/style.css"><script src="/labs/wpsm/layout/js/test.js"></script></head>
<body>
What am I missing here? I checked the character encoding of the page and it is utf-8. Any help or pointers would be awesome!
Just figured it out as I was messing around with the server. I discovered that it had mod_pagespeed enabled, I disabled the mod_pagespeed module (Google Page Speed for Apache) and it fixed the indenting and the JS file starting working. The module was automatically removing the JS file because it was a blank file I had put into the directory just to make sure the PHP was pulling the files properly. Thank you everyone for the help and I hope this helps someone save a few fistfuls of hair.