TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   need help fixing PHP code (http://www.talkphp.com/general/3924-need-help-fixing-php-code.html)

Edwin 01-30-2009 11:47 PM

need help fixing PHP code
 
can someone please help me edit this php snip for me =]

PHP Code:

'<textarea cols="'.$t_cols.'" rows="'.$t_rows.'" onclick="this.focus(); this.select();">'."\n".

'<img src="'.$imgURL.'" alt ="'.$alt.'">'."\n".

'<p><a href="'.$site_url.'">Spaceskillz Myspace Comments</a></p>'."\n".

'</textarea>'."\n"

can someone delete the img tag and the site url tag and add this part instead

HTML Code:

<style type="text/css">
body {background-image: url(.$imgURL.);
background-repeat: repeat;
background-attachment: fixed;}
</style>
<div style="position:absolute; top:0; right:0"><a href=".$site_url." target="_blank"><img src="http://i309.photobucket.com/albums/kk366/spaceskillz/spaceskillz.gif" border="0"></a></div>

Thank You =]

Salathe 01-30-2009 11:54 PM

PHP Code:

$html = <<<TALKPHP_SAVES_MY_BACON
<textarea cols="$t_cols" rows="$t_rows" onclick="this.focus(); this.select();">
<style type="text/css">
body { background-image: url(
$imgURL);
background-repeat: repeat;
background-attachment: fixed; }
</style>
<div style="position:absolute; top:0; right:0;"><a href="
$site_url" target="_blank"><img src="http://i309.photobucket.com/albums/kk366/spaceskillz/spaceskillz.gif" border="0"></a></div>
</textarea>
TALKPHP_SAVES_MY_BACON; 


Edwin 01-31-2009 12:07 AM

Quote:

Originally Posted by Salathe (Post 21488)
PHP Code:

$html = <<<TALKPHP_SAVES_MY_BACON
<textarea cols="$t_cols" rows="$t_rows" onclick="this.focus(); this.select();">
<style type="text/css">
body { background-image: url(
$imgURL);
background-repeat: repeat;
background-attachment: fixed; }
</style>
<div style="position:absolute; top:0; right:0;"><a href="
$site_url" target="_blank"><img src="http://i309.photobucket.com/albums/kk366/spaceskillz/spaceskillz.gif" border="0"></a></div>
</textarea>
TALKPHP_SAVES_MY_BACON; 


thanx dude ! =D

Edwin 01-31-2009 12:20 AM

im sorry for the double post but that code you supplied didnt work i get alot of areas so i thought about pasting the whole PHP file on here so here u go =]

PHP Code:

<?

include("config.php");

$cat $_GET['id'];
$img $_GET['img'];
$alt trim(preg_replace('/[^a-z]|((gif|jpg|jpeg|png|bmp)$)/i'' '$_GET['img']));

define("title"$alt." Myspace Graphic Comment");
define("keywords"$alt." myspace comment");
define("description""Viewing Comments ".$alt);

if(
$PBloc == '1')
$imgURL $PBURL.'cat/'.$cat.'/'.$img;
else
$imgURL $site_url.'cat/'.$cat.'/'.$img;

$uniqueID md5('graphic/cat/'.$cat.'/'.$img);

echo 
"\n".'<div align="center">'."\n".

'<div class="header">'.$alt.'</div>'."\n".

'<img src="'.$imgURL.'" alt ="'.$alt.'">'."\n";

if(
$rate == 1){
echo 
'<div align="center">'."\n".
'<script type="text/javascript">'."\n".
'<!-- //'."\n".
'document.write(\'<div\'+\' class="js-kit-rating" starColor="Blue" view="combo" path="/'.$uniqueID.'"><\/di\'+\'v>\')'."\n".
'//-->'."\n".
'</script>'."\n".
'</div>'."\n";
}

echo 
'<br />'."\n".

'<textarea cols="'.$t_cols.'" rows="'.$t_rows.'" onclick="this.focus(); this.select();">'."\n"

'<img src="'.$imgURL.'" alt ="'.$alt.'">'."\n"

'<p><a href="'.$site_url.'">Spaceskillz Myspace Comments</a></p>'."\n"

'</textarea>'."\n".

'<br />'."\n".

'<br />'."\n";

include(
"./ad.php");

echo 
"\n".'</div>'."\n";

if(
$rate == 1)
echo
'<script src="http://js-kit.com/ratings.js"></script>';

?>


Edwin 02-02-2009 09:00 PM

anyone? =[

Wildhoney 02-02-2009 09:30 PM

Hehe. That is a lot code to look through. What is it you want doing exactly in this follow-up?

Krik 02-02-2009 10:40 PM

Well I can guess why it didn't working. Trying to change the body style after the body tag has been loaded will do nothing.

Put
HTML Code:

<style type="text/css">
body {background-image: url('<?php echo $imgURL; ?>');
background-repeat: repeat;
background-attachment: fixed;}
</style>

In the <head> .. </head> of the page or at least before the <body> loads

And the "$imgURL" will need to be defined before that

PHP Code:

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

$cat $_GET['id'];
$img $_GET['img'];

$imgURL = ($PBloc == '1') ? $PBURL.'cat/'.$cat.'/'.$img $site_url.'cat/'.$cat.'/'.$img;
?>
<style type="text/css">
body {background-image: url('<?php echo $imgURL?>'); 
background-repeat: repeat; 
background-attachment: fixed;}
</style>

I do hope that the config.php defines $PBURL and/or $site_url otherwise that will cause you issues as well

Next, this
PHP Code:

'<script type="text/javascript">'."\n".
'<!-- //'."\n".
'document.write(\'<div\'+\' class="js-kit-rating" starColor="Blue" view="combo" path="/'.$uniqueID.'"><\/di\'+\'v>\')'."\n".
'//-->'."\n".
'</script>'."\n"

First, path="/'.$uniqueID.'" should be path="\'.$uniqueID. \'"

Second, <\/di\'+\'v>\' should be <\/div>\'

But worse yet you are going to have javascript write that second <div> in stead of PHP, that is a lot of unneeded code I would say
PHP Code:

if($rate == 1){
echo 
'<div align="center">
<div class="js-kit-rating" starColor="Blue" view="combo" path="\'.$uniqueID. \'"></div>
</div>
<script src="http://js-kit.com/ratings.js"></script>'
;


And as that last line, was called at the end in another "if", identical to the one above so I moved in to clean up your code

Lastly get rid of all the ."\n" they serve no purpose.

Village Idiot 02-02-2009 11:35 PM

Edwin, why are you just asking us to do particular tasks? I would be more than glad to help you with questions, but do your own basic work. What good are we actually doing for you by making simple edits? I'd suggest learning HTML so you can do these little tasks.

CoryMathews 02-03-2009 12:07 AM

Quote:

Originally Posted by Village Idiot (Post 21543)
Edwin, why are you just asking us to do particular tasks? I would be more than glad to help you with questions, but do your own basic work. What good are we actually doing for you by making simple edits? I'd suggest learning HTML so you can do these little tasks.

Agreed.

PHP Code:

<?php
$Freelabor 
"bad";

if(
$problemExists true) { //yes only 1
  
echo "Try it then ask specific help questions";
} else while(
$Freelabor == "bad") { //good luck changing that
  
echo "Go learn it yourself! try google.com";
  if(
2) break; //prove me wrong
}
?>

go run that if you need to see what it does.

Edwin 02-03-2009 01:10 AM

Quote:

Originally Posted by Wildhoney (Post 21540)
Hehe. That is a lot code to look through. What is it you want doing exactly in this follow-up?

I only need this part edited i tried a couple of times =/ but dont get nothing

PHP Code:

'<textarea cols="'.$t_cols.'" rows="'.$t_rows.'" onclick="this.focus(); this.select();">'."\n".

'<img src="'.$imgURL.'" alt ="'.$alt.'">'."\n".

'<p><a href="'.$site_url.'">Spaceskillz Myspace Comments</a></p>'."\n".

'</textarea>'."\n"

with

HTML Code:

<style type="text/css">
body {background-image: url(.$imgURL.);
background-repeat: repeat;
background-attachment: fixed;}
</style>
<div style="position:absolute; top:0; right:0"><a href=".$site_url." target="_blank"><img src="http://i309.photobucket.com/albums/kk366/spaceskillz/spaceskillz.gif" border="0"></a></div>

Quote:

Originally Posted by Krik (Post 21541)
Well I can guess why it didn't working. Trying to change the body style after the body tag has been loaded will do nothing.

Put
HTML Code:

<style type="text/css">
body {background-image: url('<?php echo $imgURL; ?>');
background-repeat: repeat;
background-attachment: fixed;}
</style>

In the <head> .. </head> of the page or at least before the <body> loads

And the "$imgURL" will need to be defined before that

PHP Code:

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

$cat $_GET['id'];
$img $_GET['img'];

$imgURL = ($PBloc == '1') ? $PBURL.'cat/'.$cat.'/'.$img $site_url.'cat/'.$cat.'/'.$img;
?>
<style type="text/css">
body {background-image: url('<?php echo $imgURL?>'); 
background-repeat: repeat; 
background-attachment: fixed;}
</style>

I do hope that the config.php defines $PBURL and/or $site_url otherwise that will cause you issues as well

Next, this
PHP Code:

'<script type="text/javascript">'."\n".
'<!-- //'."\n".
'document.write(\'<div\'+\' class="js-kit-rating" starColor="Blue" view="combo" path="/'.$uniqueID.'"><\/di\'+\'v>\')'."\n".
'//-->'."\n".
'</script>'."\n"

First, path="/'.$uniqueID.'" should be path="\'.$uniqueID. \'"

Second, <\/di\'+\'v>\' should be <\/div>\'

But worse yet you are going to have javascript write that second <div> in stead of PHP, that is a lot of unneeded code I would say
PHP Code:

if($rate == 1){
echo 
'<div align="center">
<div class="js-kit-rating" starColor="Blue" view="combo" path="\'.$uniqueID. \'"></div>
</div>
<script src="http://js-kit.com/ratings.js"></script>'
;


And as that last line, was called at the end in another "if", identical to the one above so I moved in to clean up your code

Lastly get rid of all the ."\n" they serve no purpose.

the script all works fine i just need a certain part edited as i listed below =] but thanx for helping me fix up the script =D

Quote:

Originally Posted by Village Idiot (Post 21543)
Edwin, why are you just asking us to do particular tasks? I would be more than glad to help you with questions, but do your own basic work. What good are we actually doing for you by making simple edits? I'd suggest learning HTML so you can do these little tasks.

I know some php but not alot thats why i came here for the help


Quote:

Originally Posted by CoryMathews (Post 21546)
Agreed.

PHP Code:

<?php
$Freelabor 
"bad";

if(
$problemExists true) { //yes only 1
  
echo "Try it then ask specific help questions";
} else while(
$Freelabor == "bad") { //good luck changing that
  
echo "Go learn it yourself! try google.com";
  if(
2) break; //prove me wrong
}
?>

go run that if you need to see what it does.

just thought i let you know your code wont work your gonna receive an syntax error -_-

Wildhoney 02-03-2009 01:56 AM

php Code:
$szData = '<style type="text/css">
body {background-image: url(%s);
background-repeat: repeat;
background-attachment: fixed;}
</style>
<div style="position:absolute; top:0; right:0"><a href="%s" target="_blank"><img src="http://i309.photobucket.com/albums/kk366/spaceskillz/spaceskillz.gif" border="0"></a></div>'
;

echo sprintf($szData, $imgURL, $site_url);


All times are GMT. The time now is 02:59 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0