Shopping news - Jobs search - Cheap Books - Debt Consolidation - Debt Consolidation

PDA

View Full Version : Php/sql (feel Like Crying)


scottlpool2003
Mar 9th 2009, 8:36 am
Lol...

It's driving me insane and I really need to do it!

I'm trying to call information from the database and put it in the meta tags...

It works for the title but I get errors when doing it for the tags?


Layout.php

<?php
include('config.php');

function head(){

$home = ($_SERVER['PHP_SELF'] == "/index.php") ? "homehover.png" : "home.png" ;
$new = ($_SERVER['PHP_SELF'] == "/new.php") ? "newhover.png" : "new.png" ;
$genres = ($_SERVER['PHP_SELF'] == "/genres.php") ? "genreshover.png" : "genres.png" ;

echo <<<HERE

<!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">
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7757362-1");
pageTracker._trackPageview();
} catch(err) {}</script>
HERE;

echo '


<title>';

if($_SERVER['SCRIPT_NAME'] == "/preview.php" && $_GET['id'] != 0)
{
$sql = "SELECT `title`,`genre` FROM `films` WHERE `id` = '".mysql_real_escape_string($_GET['id'])."' ";
$res = mysql_query($sql);
$rows = mysql_fetch_assoc($res);

echo "YourOnlineMovies.net | Watch ".$rows['title']." Online | Watch ".$rows['genre']." Movies Online ";
}
else {
echo "YourOnlineMovies.net | Watch Free Movies | Free Online Movies | Free Movies Online";
}

echo'
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
echo "<meta name='keywords' content='".$keywords."' />";
echo "<meta name='description' content='".$description."' />";
echo '<link type="text/css" rel="stylesheet" href="http://youronlinemovies.net/includes/public/stylesheet.css" />


<script type="text/javascript" src="youronlinemovies.net/includes/public/javascript/counter.js"></script>
<script type="text/javascript" src="http://www.youronlinemovies.net/includes/public/javascript/utilities.js"></script>
<script type="text/javascript" src="http://www.youronlinemovies.net/includes/public/javascript/JSON.js"></script>
<script type="text/javascript" src="http://www.youronlinemovies.net/includes/public/javascript/search.js"></script>
<script type="text/javasctipt" src="http://www.youronlinemovies.net/includes/public/javascript/popup.js"></script>
<script type="text/javascript" src="http://www.youronlinemovies.net/includes/public/javascript/bookmark.js"></script>



</head>

<body>

<div id="search">
<form method="post" action="" id="my_search_form" name="search_form">

<p>Search: <input borderstyle="None" type="text" name="search_query" id="search_query" onFocus=clear_search() value="Enter movie title..." size="25"/> </p><center><font color=414141><a href="http://www.youronlinemovies.net/phpBB2/index.php" title="Forum" target="_blank">Login</a> | <a href="http://youronlinemovies.net/phpBB2/profile.php?mode=register" title="Forum" target="_blank">Register</a></font>
</form>
</div>

<center><a href="http://www.youronlinemovies.net" title="Homepage"><img src="http://youronlinemovies.net/includes/public/images/logo.jpg" width="363" height="95"></a> </center>

';


echo "<div id=\"navigation\">
<a href=\"index.php\"><img src=\"http://youronlinemovies.net/includes/public/images/".$home."\" title='Homepage' /></a>
<a href=\"new.php\"><img src=\"http://youronlinemovies.net/includes/public/images/".$new."\" title='New Movies' /></a>
<a href=\"genres.php\"><img src=\"http://youronlinemovies.net/includes/public/images/".$genres."\" title='Movie Genres' /></a>
</div>

<div id='content'>";
}

function footer(){
echo <<<HERE

</div>

<div id="eXTReMe" style="display:none;"><a href="http://extremetracking.com/open?login=12345645" rel="nofollow">
<img src="http://t1.extreme-dm.com/i.gif" style="border: 0;"
height="38" width="41" id="EXim" alt="eXTReMe Tracker" /></a>
<script type="text/javascript"><!--
var EXlogin='12345645' // Login
var EXvsrv='s11' // VServer
EXs=screen;EXw=EXs.width;navigator.appName!="Netscape"?
EXb=EXs.colorDepth:EXb=EXs.pixelDepth;EXsrc="src";
navigator.javaEnabled()==1?EXjv="y":EXjv="n";
EXd=document;EXw?"":EXw="na";EXb?"":EXb="na";
EXd.write("<img "+EXsrc+"=http://e2.extreme-dm.com",
"/"+EXvsrv+".g?login="+EXlogin+"&amp;",
"jv="+EXjv+"&amp;j=y&amp;srw="+EXw+"&amp;srb="+EXb+"&amp;",
"l="+escape(EXd.referrer)+" height=1 width=1>");//-->
</script><noscript><div id="neXTReMe"><img height="1" width="1" alt=""
src="http://e2.extreme-dm.com/s11.g?login=12345645&amp;j=n&amp;jv=n" />
</div></noscript></div>



</div>

</body>
</html>
HERE;
}
?>



Calling them in from preview.php:
<?
$title = 'My title tag for this page';
$keywords = 'my keywords';
$description = 'my description';

?>

It doesn't work and I really can't work out why?

I would willingly kiss anyone who helps me with this, that's how desperate I am lol!

nabil_kadimi
Mar 9th 2009, 8:58 am
I guess something is wrong with this condition:
if($_SERVER['SCRIPT_NAME'] == "/preview.php" && $_GET['id'] != 0)

Can you please post the output of the script, only the header please.

scottlpool2003
Mar 9th 2009, 9:15 am
It can't be though because that part of the code works.

<title>';if($_SERVER['SCRIPT_NAME'] == "/preview.php" && $_GET['id'] != 0){ $sql = "SELECT `title`,`genre` FROM `films` WHERE `id` = '".mysql_real_escape_string($_GET['id'])."' "; $res = mysql_query($sql); $rows = mysql_fetch_assoc($res); echo "YourOnlineMovies.net | Watch ".$rows['title']." Online | Watch ".$rows['genre']." Movies Online ";} else {echo "YourOnlineMovies.net | Watch Free Movies | Free Online Movies | Free Movies Online"; }

It is echoing the information from the database to the <title></title> tags.

Strange huh?

sm9ai
Mar 9th 2009, 9:43 am
From how I have read this.....

You are pulling the title tags out of the database hence displaying correctly.

But you are not pulling the keywords or desciption out, hence they do not display anything.

Your title will always be set due to your if statement.

If you are pulling keyowrds and description from another file? preview.php? then it is not working for any of them? But it doesn't look like you are calling the file anyway?

scottlpool2003
Mar 9th 2009, 9:49 am
Thanks sm9ai

The coding was extremely sloppy and I didn't understand it very well so i've recoded it to the style I know, which personally I think is better.

It's working fine now, I should have done that in the first place.

I was echoing the keywords more than once but this is okay as I'm merely displaying data that is stored in the database.

<?
$title = "Watch ".$row['title']." (".$row['released'].") Free | Watch ".$row['genre']." Movies Free";
$keywords = "Watch ".$row['title']." Free, Watch ".$row['released']." movies, watch ".$row['genre']." movies, free online movies, watch free movies, ";
$description = "".$row['description']."";
?>
<?php include"includes/private/head.php";?>

That's how I'm pulling it now instead of the way I did it, i've recoded the layout page into a head.php and footer.php then used preview.php as the main content page rather than using replace codes.

Thanks again!

azizny
Mar 9th 2009, 11:14 am
There is no space between echo and '

echo'

Try doing echo '

Peace,

scottlpool2003
Mar 9th 2009, 3:19 pm
Problem already solved azizny, thanks :)