Jump to content

php issue with special characters


rileypool

Recommended Posts

Here's the script I'm using.  For some reason the html code inside the <input> tag always stop after the $value variable.  Can anybody explain to me why this happening and how I can properly address this problem?

 

<?php
$file = fopen("http://get-commented.topmsrs.com/test/urls.txt", "r") or exit("Unable to open file!"); //Output a line of the file until the end is reached

$siteURL = "http://get-commented.topmsrs.com";
$siteDescription = "get-COMMENTED!  For all your MySpace Commenting needs!";
$imgURL = array();
$i = 0;
$int = 0;

while(!feof($file)) {
$imgURL[$i] = fgets($file);
$i++;
}
fclose($file);

echo '<center>';
foreach ($imgURL as $value) {
echo '<img src="'.$value.'"><br />';
echo 'Copy & Paste the Code Below to your Profile or Comment Box<br />';
echo '<input type="text" name="Avatar '.$int.'" class="" onclick="" value="<center><a href="'.$siteURL.'"><img src="'.$value.'"><br />'.$siteDescription.'</a></center>"><br /><br />';
$int++;
}
echo '</center>';
?>

Link to comment
https://forums.phpfreaks.com/topic/79366-php-issue-with-special-characters/
Share on other sites

<? echo '<input type="text" name="Avatar '.$int.'" ?>

 

iN THE PORTION OF CODE ABOVE WOULD THE \ BEFORE THE " CARACTER COME INTO PLAY? i KNOW WHEN YOU USE ECHO"SOMETHING "; IF THERE WERE A " CHARACTER THERE YOU WOULD HAVE TO ADD \  BEFORE IT SO THAT PHP WILL RECOGNIZE IT. bUT I DONT KNOW ABOUT THIS CASE.........  echo 'SOMETHING' I havent ever tried lol NOT MY THING.

dewey_witt,

 

I might be wrong but I don't think this applies in my situation.  If I take $value out of my code the code displays perfectly.

 

I just hope I can figure this out.  Once I figure out this problem I'll be able to make my site go live.

  <?php
echo "<img src=\"$value\"><br />";
echo "Copy & Paste the Code Below to your Profile or Comment Box<br />";
echo '<input type=\"text\" name=\"Avatar $int\" class=\"\" onclick=\"\" value="<a href=\"$siteURL\"><center><img src=\"$value" alt=\"$siteDescription\"></center><br /><br />';
$int++;

?>

 

 

Hey try this........ Dont be scared to test this stuff useing the html tags... I know I know there is a standard but ehe

<?php

foreach ($imgURL as $value) {
echo '<img src=\"".$value."\"><br />';
echo 'Copy & Paste the Code Below to your Profile or Comment Box<br />';
echo '<input type=\"text\" name=\"Avatar ".$int."\" class=\"\" onclick=\"\" value=\"<center><a href=\"".$siteURL."\"><img src=\"".$value."\"></a><br />".$siteDescription."<center><br /><br />";
$int++;
}
echo '</center>';

?>

 

Try this I changed it a lil.

Thanks again to everybody for their help but I changed my code to this and it worked like a charm.  Plus its quite a bit simpler and easier to read!

 

echo '<textarea name="Avatar '.$int.'" cols="80" rows="3"><center><a href="'.$siteURL.'"><img src="'.$value.'"><br />'.$siteDescription.'</a></center></textarea><br /><br />';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.