why hyperlink with www does not visible - php

I was trying to make an hyperlink, I found something I don't understand.
The hyper link below doesn't show up on my html view with www in it.
href='http://www.ringtonematcher.com/co/ringtonematcher/02/noc.php?sid=EULDros&artist=$ringtone_artist&song=$ringtone_title
but when I remove www it start showing up
href='http://ringtonematcher.com/co/ringtonematcher/02/noc.php?sid=EULDros&artist=$ringtone_artist&song=$ringtone_title
Is there any explanation?
Thankyou
EDIT 1
Here is my view source
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/assets/css/style.css" type="text/css" media="screen" />
<title>Music Engine</title>
</head>
<body>
<div id="mainbody" class="wrapper">
<script src="http://connect.soundcloud.com/sdk.js"></script>
<script>
SC.initialize({
client_id: "6a43a20c7a9e04da8d722bb01f16ce49",
});
SC.get('/tracks/106285389',function(track){SC.oEmbed(track.permalink_url, document.getElementById("player"));})
$(document).ready(function() {
});
</script>
<div id="player"></div>
<a class="download" href="http://api.soundcloud.com/tracks/106285389/download?client_id=6a43a20c7a9e04da8d722bb01f16ce49">Download</a>
<div class="ringtone_matcher"><a class='download' href='http://www.ringtonematcher.com/co/ringtonematcher/02/noc.php?sid=EULDros&artist=Carly Rae Jepsen&song=Call Me Maybe'>Send Ringtone to your cell</a></div>
</div>
</body>
</html>
what i mean not visible is i can't see it in the browser but i can see it inside the source

www.ringtonematcher.com is on a list of unwelcome advertising sites in AdBlock, which applies a stylesheet which applies display: none to links to it. The site without the www. is not on that list.
Disable your AdBlock extension to see it.

The problem would seem to be from the fact that you aren't effectively "showing" the language of PHP that you have variables in your code.
<div class="ringtone_matcher">
<?php echo "<a class='download' href='http://ringtonematcher.com/co/ringtonematcher/02/noc.php?sid=EULDros&artist=".$ringtone_artist."&song=".$ringtone_title."'>";
echo "Send Ringtone to your cell</a>";
?>
</div>
This would, at least, be a more correct way of doing it.

Related

How to control relative path in php

In my project, I have a problem for href.
my html page is a.php, and its code is :
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="http://www.ulpin.com /css/bootstrap.min.css">
<style>
dd{word-wrap:break-word;};
</style>
<title>SystemTitle</title>
<script type="text/javascript" src="static/js/jquery-1.7.2-min.js"> </script>
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
<base target="_self"/>
</head>
<body>
<br/>
<br/>
<br/>
<br/>
<div class="container">
<center>
ManTest<br/><br/>
</center>
</div>
</body>
</html>
But it works fail. So I checked the page source code with firefox, When I click the href of static/js/jquery-1.7.2-min.js, it shows:
Not Found
The requested URL /o1ws1v/web/admin/static/js/jquery-1.7.2-min.js was not found on this server.
The src is changed. "/o1ws1v/web/admin/" is added auto.
Why?
My fold struct is :
/yjdata/www/www/o1ws1v/web/admin/a.php
/yjdata/www/www/o1ws1v/web/static/js/jquery-1.7.2-min.js
/yjdata/www/www/o1ws1v/web/static/js/bootstrap.min.js
Otherwise, a.php is put in /yjdata/www/www/o1ws1v/web/, it works OK
Who can help me?
This is a simple problem of paths.
When you are under /yjdata/www/www/o1ws1v/web/admin/a.php and use src="static/js/jquery-1.7.2-min.js", this is waht happens :
--/yjdata/www/www/o1ws1v/web/admin/
| |--- a.php <-- You are here
| |--- static/ <-- This is where the browser think that the static folder exists
|--- static/ <-- This is where the folder really is !
So, what you need to do in the a.php is to go up a level in the src path :
<script type="text/javascript" src="../static/js/jquery-1.7.2-min.js"> </script>
The .. to indicate the parent directory.

PHP include a file with an included file -> scripts and variables get included but seem echo'd

I am having troubles with including a file that has an included file with some js script library's in it.
index.php
<?php
include 'header.php';
?>
<section>
<div>
<p>misc. html</p>
</div>
</section>
<?php
include ($_SERVER['DOCUMENT_ROOT'].'/footer.php');
echo 'test ='.$testVar;
?>
footer.php
<?php
include ($_SERVER['DOCUMENT_ROOT'].'/includes/footerscripts.php');
?>
</body>
</html>
/includes/footerscripts.php
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<?php
$testVar = 'test';
?>
In that scenario, the index file does have this in the source code when ran:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
test =
The scripts are making their way there but are not being executed and the variables aren't coming through either.
When I change the footer.php to include those scripts and variable directly, the variable makes it to index.php, so do the scripts but they don't execute (or not on time?).
Any ideas guys?
I have a weird php5.ini file as I didn't know what all to put in it, if that makes a difference. The include file path seems okay as it still works for the most part.
Thanks,
Matt
Edit: Added the include ('header.php') which works fine and pulls in my header.
That file looks like:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="--">
<meta name="keywords" content="--">
<meta name="author" content="--">
<title>--</title>
<link rel="stylesheet" href="/css/mainstylesheet.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="icon" href="/images/favicon.ico">
</head>
<body>
<header class="nav-top" id="top" role="navigation">
<div class="container">
<div class="home-link">
<img src="/images/logo/logo-p.png" alt="plc" class="logo" />
</div>
<nav class="nav-main">
<ul>
<li>
Home
</li>
<li>
Portfolio
</li>
<li>
Contact
</li>
</ul>
</nav>
</div>
</header>
Edit: Guess I just needed my jquery loaded from the header of the document, because it works that way. I still can't carry variables from grandchild to parent but oh well
According to your example the index.php file is missing something:
<?php
include ($_SERVER['ROOT'].'/footer.php');
echo 'test ='.$testVar;
?>
I assume that you didn't post the whole file, since here the output hmtl here is not valid - missing html opening tag, etc. Could you please provide the whole and/or simplified index file?
Replace all instances of $_SERVER['ROOT'] with $_SERVER['DOCUMENT_ROOT'].

HTML / PHP: Which parts of an HTML head can be saved in a separate file

I am new to HTML and hope someone can help me with this.
I am trying to set up a website where the code for every page is saved as a separate php file.
Since all these pages use the same document head and includes I would like to remove as much as possible of this from the pages and save it in a separate includes file (header.php) which I can then include using PHP.
My current head looks as follows and since this is the same on all pages I currently have ALL this saved in the separate header.php file and then just use <?php include "header.php"; ?> on the single pages.
Can someone tell me which parts of this should remain on the single pages for a proper setup and if anything should be changed or added here ?
Note: jQuery and JS are included separately in the footer.
My PHP (header file):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="John Doe" />
<meta name="description" content="Created: 2015-06" />
<base href="http://www.MyURL.com" target="_self" />
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="includes/styles.css" />
<!-- CSS - Font Awesome -->
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<title>My Page</title>
</head>
<body>
<div class="wrapper">
<!-- ... -->
Your Top head file (top_head.php):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php if(isset($page_author)){ ?>
<meta name="author" content="<?php echo $page_author; ?>" />
<?php } ?>
<?php if(isset($page_description)){ ?>
<meta name="description" content="Created: 2015-06" />
<?php } ?>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="includes/styles.css" />
<!-- CSS - Font Awesome -->
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<title><?php echo $page_title; ?></title>
Your current header file:
<?php
$page_title = 'Hello';
$page_description = 'This is a beautiful description';
?>
<?php include("top_head.php"); ?>
</head>
<body>
<div class="wrapper">
<!-- ... -->
Since you are starting your tag in header.php, you can close the tag on the own page itself (i mean the other pages ie: Contact, About Us, Product, etc...).
The code section you have mentioned in the question can be called as header.php and further can be included on each and every page where it is required.
Apart from this
Header - header.php
Main content - main-content.php - this will be specific to each and every page from your website
Footer - footer.php - this can also be made common - and further included in every page.
Apart from this you can also have a few more php files which might have navigation or any kind of common content blocks.
Example page could be:
<?php
include 'header.php'
/*either add here the content or include further php files*/
include 'about-us.php'
include 'footer.php'
?>
You are doing right, the parts that are shared between all the pages should be placed in a separate php file, this greatly improve your life when you have to maintain the site (immagine add a stylesheet or a library to every page of your site after some time ...).
To help SEO you should specify a title and maybe some meta tag that are page specific.
Also consider carefully if you have other parts that are repeated in every page for example a left or right bar or a particular widget (for example a banner image or something like that)
This should give you the general idea...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="John Doe" />
<meta name="description" content="Created: 2015-06" />
<base href="http://www.MyURL.com" target="_self" />
<!--
Your paths need to relative to the websites root directory or the full
URL else they may not work depending on where the file is located.
-->
<link rel="stylesheet" type="text/css" href="/includes/styles.css" />
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
<!--
This line just echos the title if one has been set or a default string
if the title hasn't been set. You will need to ensure every page that
includes this file sets the title before including this file. You may
also want to take this approach with other values.
-->
<title><?php echo isset($title) ? $title : 'Default Title'; ?></title>
</head>
<body>
<div class="wrapper">

Including a CSS file in a PHP file that is included in a PHP file

I have a php file that doesn't (for now) use any php code, that holds code for the header and main menu that will be used across all pages. The CSS file has no effect, even though I've created a style class for h1. The text "TEST" shows up, but the style is not applied. How do I properly include the CSS file?
mainMenu.php
<!--This code is included within the <head> of each page, and the stylesheet for the header and main menu are included here-->
<link href="styles/headerMenu.css" ref="stylesheet" type="text/css">
<!--Header and menu code-->
<div>
<h1>TEST</h1>
</div>
index.php
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>untitled</title>
<?php include ('./includes/mainMenu.php') ?>
</head>
<body>
</body>
</html>
The CSS file is not found. Double check the link and correct it:
<link href="menu.css" rel="stylesheet" type="text/css">
^- REL not REF
Also to prevent additional problems, remove the start and end tags of <head> and <body> from the code. The way you output the HTML elements, you would create wrong HTML if you keep those tags. Remove them and your page will be valid HTML again.
index.php:
<!DOCTYPE html>
<html>
<meta charset="utf-8" />
<title>untitled</title>
<?php include ('menu.php') ?>
</html>
Valid HTML has the benefit that you can run it through a validator to spot errors early.
I think it may be because you have got your menu appearing inside your <head> tag.
The CSS needs to go inbetween the <head> and </head> but the rest needs to be inside the <body> tag
<link href="styles/headerMenu.css" rel="stylesheet" type="text/css">
This must be at <HEAD></HEAD>
<div>
<h1>TEST</h1>
</div>
This must be at <BODY></BODY>
You have to separate this file into 2 files and include them in Head and in Body..
Don't include your HTML code in HEAD part. Only include CSS and JavaScript files in HEAD section. and you need to prefix the css or images path in some php file.
E.g.
create new php file with name "conn_path.php"
<?php
define('SITE_PATH',$_SERVER['DOCUMENT_ROOT'].'siteName/');
define('SITE_HTTP_PATH','http://localhost/'siteName/');
define('CSS_PATH','http://localhost/siteName/styles/');
define('IMAGE_PATH','http://localhost/siteName/images/');
?>
And then you path will be like below:-
mainMenu.php
<?php include "conn_path.php" ?>
<link href="<?php echo CSS_PATH ;?>headerMenu.css" rel="stylesheet" type="text/css">
It will help you in whole project…
Create a template file, with your essential (and re-used) html. Also with <html>, <head> and <body> tags and anything you must have in all pages – As your stylesheets and menu.
Then add a content section with a single variable.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>untitled</title>
<link href="styles/headerMenu.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--Header and menu code-->
<div>
<h1>TEST</h1>
</div>
<?php echo $page_content; ?>
</body>
</html>
This way, any page content shoud be assigned to $page_content instead of echoed.

Head tags displays inside body on CakePhp

I have a strange error on CakePhp 2.0 where the head tags renders empty, and all the tags that belongs to head, renders into the body before any content.
This his how the layout default.ctp looks:
<!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>
<?php echo $this->Html->charset(); ?>
<title>
<?php echo $title_for_layout; ?>
</title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->script(array('librerias/jquery.tools.min'));
echo $this->Html->css('cake.generic');
echo $this->Html->css('webfront');
echo $scripts_for_layout;
?>
</head>
<body>
<div id="container">
<div id="header">
</div>
(the rest of the html render)
</body>
</html>
And this is how it's rendered, as firebug says:
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body>

<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title> Usuarios </title> **(IE moves the title tag on the head manually, it seems)**
**(IE displays the DOCTYPE on its debugging console here)**
<link rel="icon" type="image/x-icon" href="/web/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="/web/favicon.ico">
<script src="/web/js/librerias/jquery.tools.min.js" type="text/javascript">
<link href="/web/css/cake.generic.css" type="text/css" rel="stylesheet">
<link href="/web/css/webfront.css" type="text/css" rel="stylesheet">
<div id="container">
<div id="header"> </div>
(the rest of the html render)
</body>
</html>
It's bad enough because it distorts the DOCTYPE tag and makes IE render the page very buggy.
Also, I have another test site where it doesn't happen this error. In fact I switched layouts and the error was the same.
Does someone knows why this happens? I couldn't find anything similar on the web and I don't have any clue about this. Any help will be appreciated.
Thanks in advance
Finally we got the answer for this problem. It was Cake's php and the infamous character &#65279 that appeared on utf-8 encoding. By changing every encoding on php files that passed before the final layout, we solved the problem.
Thanks for your help :)
you have file with BOM char . use BOM Detector program
java : http://www.javapractices.com/topic/TopicAction.do?Id=257 [recommended][find and remove]
1- check URL for exist BOM
2- remove BOM from your file
php : http://www.dotvoid.com/2010/04/detecting-utf-bom-byte-order-mark/
You are missing one end tag in the layout file.
<body>
<div id="container">
<div id="header">
</div>
(the rest of the html render)
</body>
</html>
It should be corrected as follows
<body>
<div id="container">
<div id="header">
</div>
(the rest of the html render)
</div>
</body>
</html>

Categories