I'm new in PHP PLease help

Hi sitepoint users,

I have a problem ,

the problem is that i can’t make permalinks in the way that i want to, i need that mi site work with permalink like this www.mysite.com/eminem/ and i don’t have any success i will ad the code from search.php file and .htaccess

search php file

include 'config.php';
include 'function.php';

<!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" dir="ltr" lang="en-US">

<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title><?if (empty($q)){echo "Videos - $atitle";}else{echo "$q watch, ".strtoupper($q)." download, listen to".ucwords($q).", $q videos", " Page $syf";} ?></title>
<meta http-equiv="Content-Language" content="en">
<meta name="description" content="<?=$q?> videos, <?=strtoupper($q)?> watch, listen to <?=ucwords($q)?> , <?=$q?> search" />
<meta name="keywords" content="listen to <?=$q?>, <?=strtoupper($q)?> watch, <?=ucwords($q)?> download, <?=strtoupper($q)?> search youtube. " />

<link rel="stylesheet" href="style.css" type="text/css" media="screen" />

<!--[if IE 7]>
<link rel="stylesheet" href="style-ie7.css" type="text/css" media="screen" />
<!--[if IE 6]>
<link rel="stylesheet" href="style-ie6.css" type="text/css" media="screen" />


<div id="main">

<? include 'header.php'; ?>

	<div id="content">
		<div class="sidebar_left">

		<li class="categories"><h2>Categories</h2>
foreach ($kategori as $sirala){
echo '<li class="cat-item cat-item-55"><a href="./'.$sirala.'&page">'.$sirala.'</a></li>';
		<div class="homebody2">
			<div class="randomposts">
		<h2 class="pagetitle"><?if (empty($q)){echo 'Videos';}else{echo "listen to $q, ".strtoupper($q)." watch video, ".ucwords($q)." download, $q clips";} ?></h2>
			<div class="whatsnew">
<div id="ads728"></div>
//Rastgele veri al&#305;n&#305;yor

if (empty($sayfada)){$sayfada='20';}else{$sayfada=$sayfada;}
if (empty($syf)){$syf=1;}else{$syf=$_REQUEST['syf'];}
if ($syf=="1"){
if (empty($q)){$q=$anaara[0];}else{$q=$_REQUEST['q'];}

if (empty($listele)){$listele='relevance';}else{$q=$_REQUEST['q'];}

if ($toplamkayit<=0){
echo "Video Bulunamad&#305;";
for ($i=0;$i<=$bulsay;$i++){
preg_match_all('#<title type=\\'text\\'>(.+?)</title>#smi',$bul[$i],$title);
preg_match_all('#<gd:rating average=\\'(.+?)\\' max=#smi',$bul[$i],$rating);
preg_match_all('#<media:description type=\\'plain\\'>(.+?)</media:description>#smi',$bul[$i],$aciklama);
preg_match_all('#<media:thumbnail url=\\'(.+?)\\' height=\\'90\\'#smi',$bul[$i],$th);
preg_match_all('#<yt:duration seconds=\\'(.+?)\\'/>#smi',$bul[$i],$sure);
$kalan=$sure % 60;
if ($kalan=="0"){
					<div class="posts2"><h2></h2>
						<div class="postimage">
							<a href="<?=seolinkvideo($vid,$title)?>" title="<?=$title?>"><img src="<?=seolinkres($vid,$title)?>" width="120" height="72" alt="<?=$title?>" /></a>
						<div class="postinfo">
							<a href="<?=seolinkvideo($vid,$title)?>" title="<?=$title?>"><?=kisalt($title,30,'...');?></a>
						<div class="postviews">
						<div class="postviews">
							<?=$viewsay?> views  


	<div class="whatsnew">
<div id="ads729"></div>
		<div id="pagination">
$total_records = $toplamkayit; // toplam veri say&#305;s&#305;
$scroll_page = 15; // kayd&#305;r&#305;lacak sayfa say&#305;s&#305;
$per_page = $sayfada; // her sayafa gösterilecek sayfa say&#305;s&#305;
$current_page = $_GET['syf']; // bulunulan sayfa
$pager_url = ''.urlencode($q).'&page'; // sayfalaman&#305;n yap&#305;ld&#305;&#287;&#305; adres
$inactive_page_tag = 'syf='; // aktif olmayan sayfa linki için biçim
$previous_page_text = '<'; // önceki sayfa metni (resim de olabilir <img src="... gibi)
$next_page_text = '>'; // sonraki sayfa metni (resim de olabilir <img src="... gibi)
$first_page_text = '<<'; // ilk sayfa metni (resim de olabilir <img src="... gibi)
$last_page_text = '>>'; // son sayfa metni (resim de olabilir <img src="... gibi)

$kgPagerOBJ = new kgPager();
$kgPagerOBJ -> pager_set($pager_url, $total_records, $scroll_page, $per_page, $current_page, $inactive_page_tag, $previous_page_text, $next_page_text, $first_page_text, $last_page_text,$pager_url_last);

echo '<p align="center" id="pager_links">';
echo $kgPagerOBJ -> first_page;
echo $kgPagerOBJ -> previous_page;
echo $kgPagerOBJ -> page_links;
echo $kgPagerOBJ -> next_page;
echo '</p>';

<? include 'footer.php'; ?>

<div id="ads728loader" style="display:none;"><? include '728.php'; ?></div>
<script type="text/javascript">
document.getElementById("ads728").innerHTML = document.getElementById("ads728loader").innerHTML;
<div id="ads729loader" style="display:none;"><? include '728.php'; ?></div>
<script type="text/javascript">
document.getElementById("ads729").innerHTML = document.getElementById("ads729loader").innerHTML;

and the .htaccess file

RewriteEngine on
#RewriteBase /
ErrorDocument 404 /404.shtml
RewriteCond %{HTTP_HOST} ^www.mysite.com [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301]
RewriteRule ^videolar.html ara.php [L]
RewriteRule ^contact.html iletisim.php [L]
RewriteRule ^privacy.html privacy.php [L]
RewriteRule ^dmca.html dmca.php [L]
RewriteRule ^links.html links.php [L]
RewriteRule (.*)-(.*).html video.php?vid=$2 [L]
RewriteRule (.*)-(.*).jpg resim.php?res=$2 [L]
RewriteRule ^(.*)&page([0-9]*) ara.php?&q=$1&syf=$2

#cv eski videolar

RewriteRule (.*)!(.*).html video2.php?act=video&vid=$1 [L]
RedirectMatch 301 ^(.*)sex(.*)$ http://mysite.com/
RedirectMatch 301 ^(.*)fight(.*)$ http://mysite.com/
RedirectMatch 301 ^(.*)porn(.*)$ http://mysite.com/
RedirectMatch 301 ^(.*)gilma(.*)$ http://mysite.com/

Thanks in advance

38 views and no one can’t help me ?

did you write all this code?

if so, why have you got html and javascript code in between the </body> and </html> tags which is not mormal?


That code is for advertisment , first will load the website body then the advertisment this make mi site faster with 80%


ok, but I don’t see how having code between your </body> and </html> tags makes your site faster.


Thanks for reply , Well its easy, after the body content loads the document.getElementById loads the div id <div id=“ads728”></div> on the site that miens that after the site completely loads the div id retrieve the advertisement , if you don’t knew the advertisement slow down the websites even with 80% because the advertisement needs to completely load to continue the next step got it ?

sorry for my bad english



i will give you a site where explain you better advertisement


Can you help me with mi problem ?


I rewrite without the trailing slash (you really do not need it and it is just an extra character that does not need to be there in my opinion). My rewrite structure is as follows:


What happens is that the URL is rewritten to a PHP file which uses a switch statement to determine which resource to show based on the URL.

See these threads for an idea.


If you have further questions about rewriting, the Apache Configuration is the place to ask about rewriting on Apache.

As for the javascript after the body tag but before the HTML tag, that is a little unusual. The javascript is often placed just before the body tag and after everything else. That way, the rest of the page will render before the javascript comes into play so the javascript does not slow down the rendering of the page. I think the javascript should be inside the body tag. I don’t know if it makes a difference, but that seems to be how the majority of people suggest it be done as far as I have seen.

Hi cheesedude,

Thanks allot for your reply, i have tried all that articles and i don’t have any success can you please give me an example for mi files or if you can/have time change the files and show me how and what i need to do thanks for your help


I doubt if it will help with your rewrite woes, but the script and div tags should be before the closing body tag like so:

<? include 'footer.php'; ?>


<div id="ads728loader" style="display:none;"><? include '728.php'; ?></div>

<script type="text/javascript">

document.getElementById("ads728").innerHTML = document.getElementById("ads728loader").innerHTML;


<div id="ads729loader" style="display:none;"><? include '728.php'; ?></div>

<script type="text/javascript">

document.getElementById("ads729").innerHTML = document.getElementById("ads729loader").innerHTML;



Hi, thanks for your suggestion but the code works very fine outside the ?</body> tag , if i add in <body> tag i get double ads i get 2 ads instead of 1

Regards ILIE

have you looked at how Wordpress handles rewrites/permalinks?

And why do you get 2 ads when moving the HTML/JS to before the </body> tag? The adsloader divs are set to display:none so they should not be visible.

HI siteguru Thanks for your reply,

i have solved that problem with </body> double ads showed up , now about permalinks my script don’t use wordpress only the template is from a wordpress theme the functions and all this stuff ar not from wordpress you ar 2 person ho told me that i need to look at the Wordpress handles rewrites/permalinks , why do you think that is a wordpress script ?

Regards ILIE

What you are wanting to do looks very like what Wordpress offers. So looking at HOW Wordpress does this might give some clues on how YOU should do it. :slight_smile:

$wp_rewrite is the variable that Wordpress uses. I’ve not found as yet the section of code/class that implements the rewrite functionality.

Edit: This may or may not help :slight_smile:

Me again! :slight_smile:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /musings/
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /musings/index.php [L]

That’s the .htaccess from my own Wordpress blog. In there my posts take the form like this as permalinks:

I don’t know if this helps you or not. :lol:

Hi siteguru,

Thanks again for your reply and help , unfortunately mi site is not functions based on wordpress due that mi site don’t have a database and another functions related to wordpress , mi site use youtube gdata api it’s fully automatically i need to figured out this problem or maybe like you seed i don\ need to change permalinks are good even in this way , the new permalinks that i made are mysite.com/eminem&page1 etc… sow i think will be good nought for google index what you think ?

Regards ILIE

It works fine because browsers are coded to try to help developers. So when it sees your code between </body> and </html> it thinks you typed/pasted in the wrong spot versus “trying to make ads load last”. Which, is bad practise.

Hi rguy thanks for your reply , i have solved that problem woos a mine mistake woos exacly how you seed “i tryied to make ads load last” and now i have pasted before /body tag

Regards Ilie

What might help is if you post an EXACT LINK of what the API/your page expects to see, and then post an EXACT LINK of what you would like this to appear as in the browser.

Ultimately this seems to be an Apache Rewrite issue - it’s just a case of getting the right rule set. :slight_smile: