I have 3 files created in dreamweaver 1)mainfile.php 2)sidecolumn.php 3) style.css. Now I linked the css file with main file and called the sidecolumn file with the code
<?php include('sidecolumn.php');?>
I'm able to see the sidecolumn in the main file (in design view of dreamweaver) but the problem is when i tried to run in the browser, it is completely blank.
This is the code for mainfile.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="mystylesheet.css" media="screen" />
</head>
<body>
<div class="right"> <!----this the wrapper in stylesheet---->
<?php include('sidecolumn1.php');?>
</div>
</body>
</html>
This is the code of sidecolumn1.php
<div class="sidecolumn">
<div class="box_1b box_x">
<div class="name_1 round_corner_top">Video categories:</a></div>
<ul class="list_2">
<li>Site1</li>
<li>Site2</li>
<li>Site3</li>
</ul><!--/list_1-->
<div class="slideDown">More [+]</div>
</div><!--/box_1b-->
<div class="box_1b box_x">
<div class="name_1 round_corner_top">Video categories:</a></div>
<ul class="list_2">
<li>Site4</li>
<li>Site5</li>
<li>Site6</li>
</ul><!--/list_1-->
<div class="slideDown">More [+]</div>
</div><!--/box_1b-->
</div>
I'm testing with on my local pc. the url is d:\mydocuments\mysite\main.php
PHP is (in this context) a server side programming language.
It must be interpreted by a web server (which needs to support PHP).
You can't load the file directly into your browser from your file system.
You must set up a web server and access it via an http:// (or https://) URI.
Related
I have a very basic question I just can't seem to figure out or find the answer too. My php won't work on my local host (wamp) or when i upload it to my website/server.
I simply want to "include" two files on my index.php file to display additional html. For whatever reason, the php won't work and won't display anything outside of what is currently in my index.php file.
Here is my index.php
<php? include 'inc/header.php';?>
<div class="container">
<p>main content.what is going on</p>
</div>
<php? include 'inc/footer.php';?>
here is an example of my header.php file..
<!doctype html>
<html>
<head>
<title>stuff</title>
<link rel="stylesheet" href="reset.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Is stuff here?</h1>
</header>
I just can't seem to figure it out and any thoughts would be VERY helpful.
You have PHP start tag wrong. It should be
<?php
I have a php-file called loginscreen.php. For now it contains two JqueryMobile pages and a form on the first page to login. The login process is working just fine. The whole thing is hosted with xampp (Version: 5.6.3-0) on my Mac.
When I change the file extension of my loginscreen.php file to .html (so --> loginscreen.html) and open it in the htdocs folder in finder, the loginscreen page opens just fine in Safari in correct jquery mobile style after my custom theme, the login process works and gets me to my second page.
However, if I access the loginscreen.php in my browser with localhost/loginscreen.php the file renders wrongly. I get double buttons (usual html button within jQuery button). Double input fields (same as buttons). My second page is being displayed as well and when login in I get a page load error!
What's my problem here? Since it works when opening the file as an html via finder I suppose the problem is my xampp hosting. What could the problem be so that my files don't render correctly when hosted via xampp?
My code (The loginscreen.php file)(There's also a javascript and another php file being responsible for the login via ajax and php to access my database (also hosted with xampp) everything working properly when being opened via finder as html but not when accessed through browser as php)
<!doctype html>
<html><head>
<title>Prototyplogin</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <meta name="viewport" content="initial-scale=1, maximum-scale=1"> -->
<link rel="stylesheet" href="themes/mensa1.min.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="jquery/jquery.mobile.structure-1.4.5.min.css" />
<link rel="stylesheet" type="text/css" href="loginscreen.css" />
<script type="text/javascript" src="jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="jquery.mobile-1.4.5.js"></script>
<script type="text/javascript" src="loginscreen.js"></script>
</head>
<body>
<div data-role="page" data-theme="c" id="loginscreen">
<div data-role="main" class="ui-content">
<br />
<div id="titel">
<p>Logo</p>
</div>
<br />
<form action="test.php" method="post" id="loginformular">
<label for="username">Benutzername:</label>
<input type="text" name="username" id="username">
<br/>
<label for="password">Passwort:</label>
<input type="password" name="password" id="password">
<br/>
<input type="button" value="Anmelden" id="submit" data-role="button">
</form>
<div id="notificationdiv"><h3 id="notification"></h3></div>
</div>
</div>
<div data-role="page" id="firstpage">
<div data-role="header">
</div>
<div data-role="main" class="ui-content">
<h1>Secondpage</h1>
</div>
<div data-role="footer">
</div>
</div>
</body>
</html>
Searched the whole internet for this issue, would be awesome to receive some help! :-)
Thanks for your help in advance! :-)
I figured out the problem myself. The problem didn't have anything to do with my XAMPP installation. I figured out the two actual problems:
My PHP file didn't have the header('Content-Type: text/html; charset=utf-8'); and there for I ran into errors and misbehavior of my code, because my index.php file was set to utf-8 with a meta tag, but without the header('Content-Type') my PHP code wasn't.
My Jquery-Mobile CSS wasn't wrongly imported. I only imported the Jquery-Mobile-Strucutre.css after my theme instead of the normal Jquery-Mobile.css. This was responsible for the double renderings and wrong displays as well as for the wrong page display behavior, because some crucial page elements are missing when not importing the standard Jquery-Mobile.css.
Hope this helps some other people running into these issues, took me quite a while to figure out the encoding issue with utf-8.
I have a php page where I have the code posted below. My main problem was that in the header there was a line added at the top. This line was not added at the other .html files of my page that used exactly the same code. The only difference was the extension (html and php).
I tried "inspect element" feature to see what is going on. And I can see a different code in the <head> and the <body>.
My page code :
<!DOCTYPE html>
<?php
session_start();
include("conf.php");
$current="gallery.php"
?>
<html lang="en">
<head>
<title>.......</title>
<meta charset="utf-8">
<link rel="stylesheet" media="screen" href="......css">
<!-- JS -->
<script src=".................."></script>
</head>
<body>
<!--==============================header=================================-->
<header>
<div class="container_12">
<div class="grid_12">
<h1><img src="images/logo.png"> </h1>
<div class="menu_block">
<nav>
<ul class="sf-menu">
<li>ΑΡΧΙΚΗ </li>
...
...
<li>ΕΠΙΚΟΙΝΩΝΙΑ </li>
</ul>
</nav>
<div class="clear"></div>
</div>
</div>
</div>
</header>
...
...
</body>
What causes that ? I have the same html code (and css) in the other pages (different extension though) like this one : HTML version
Your webserver is set up to only interpret files with .php extension as PHP scripts. Whenever you give the page the .html extension, it will just send the file to the browser to interpret, without parsing it beforehand. So everywhere you use php code you should give the file the .php extension (or change the webserver's configuration, but I wouldn't do that now).
In a web app I am developing, I am experiencing a difference in placement in the DOM of elements when testing between Chrome and Firefox.
When viewing the page in Chrome, elements from the <head> tag seem to be placed in the <body>, along with a bit of whitespace. This does not appear when viewing the site in FireFox.
What could cause element missplacement like this? http://archives.wsusignpost.com
I am generating the page in PHP, pulling in data from a MySql database.
db.php is included in header.php, which is included in index.php
header.php:
<?php require('db.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title>The Signpost: Archives</title>
<meta name="keywords" content="..." />
<meta name="title" content="..." />
<meta name="description" content="..." />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<a href="http://www.wsusignpost.com">
Main Signpost Website
</a>
<h1>
<img id="banner" src="..." \>
</h1>
I base myself on #Lachlan insightful answer, and expanding on that:

represent the Byte Order Mark symbol as rendered on the page. Being there 2 of them, looks like both files (main page and required one) are saved with UTF-8 with BOM, and that may cause the rendering problems (coming before the DOCTYPE).
Try saving your files as UTF without BOM in your editor and see if that solves the problem.
The first two lines of your server's response is:
<!DOCTYPE html>
<html>
Not entirely sure what that  is doing there, but I suspect your PHP require() is including something odd. Your page, when saved, completely crashes TextMate --- so something certainly isn't normal.
I intent to create a template PHP file, this template will only serve the design, not the content. The purpose is to decrease the development time in a sense that when creating a new PHP file or new module, I can only need to concentrate on the main function of that PHP file not the design. Once I created the new file using the template, it should be able to display the consistent design and serve its specific function.
The issue is that I am not sure on how to make the design of the template works and applied to all of the new files created regardless of the location (as long as it is within the root directory).
As an example:
root directory (www.example.com): /
homepage (www.example.com/index.php): /index.php
css file: /style/style.css
template file: /template.php
newly created file (www.example.com/subone/find/css/file.php): /subone/find/css/file.php
another newly created file (www.example.com/subtwo/locate/css.php): /subtwo/locate/css.php
Content of the homepage (which is created base on the template.php, but the CSS file location is hard coded):
<html>
<head>
<title>Testing</title>
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<body>
<div id="header">logo and login form goes here
<div class="nav"> navigation goes here;</div>
</div>
<div id="main">main content goes here;</div>
<div id="footer">footer goes here; </div>
</body>
</html>
but, when I created a new file, /subone/find/css/file.php
the location of the css must be changed and specified manually, like this:
<html>
<head>
<title>Testing</title>
<link rel="stylesheet" type="text/css" href="../../../style/style.css" />
</head>
<body>
<div id="header">logo and login form goes here
<div class="nav"> navigation goes here</div>
</div>
<div id="main">main content goes here;</div>
<div id="footer">footer goes here;</div>
</body>
</html>
So, what I want to achieve is that, when creating a new file (/subone/find/css/file.php), I don't need to do anything, I can straight away concentrate on the main section:
<html>
<head>
<title>Testing</title>
...style.css is handled automatically
</head>
<body>
<div id="header">logo and login form goes here
<div class="nav"> navigation goes here</div>
</div>
<div id="main">main content goes here;
<?php
//I can continue to edit the file from this line onward
echo "I am concentrating on the main function of file.php right now!!";
?>
</div>
<div id="footer">footer goes here;</div>
</body>
</html>
example page can be seen at (only the desired design): neoborn.kodingen.com
I accept any answers as long as it can achieve my intention (template).
Thank you :)
Why don't you use absolute paths when referring to CSS files and other resources in your template file?
For example:
<link rel="stylesheet" type="text/css" href="/style/style.css" />
There are 2 options,
Use absolute paths for your css files <link rel=stylesheet href="/style/style.css">
Use HTML's <base> element to cause all relative paths on the page relate to it.
I would use a easy to install template engine. That will help speed up development and still give you the freedom to do whatever PHP you like.
Try http://www.raintpl.com/ that should be quick and easy for you to install and get back to coding the pages. If you include it in your PHP inc folder, it will be available for every PHP file you create. So you won't need to add an include line at the top of each PHP file.
Index.php
<?php define('BASE_URL', 'http://localhost'); ?>
Template.php
<link rel="stylsheet" type="text/css" href="<?php echo BASE_URL; ?>/style/style.css ?>" />