Jump to content

Couple problems


Praetorian

Recommended Posts

I'm using this script to change the color of a link based on output from a database. I can't quite get it to work right...All the links work fine except for this one. I've tried several variations of the matching in the php portion, but none of them work. I've tried matching it exactly as it appears in the link, I've tried replacing the amp with the actual symbol, and replacing the + with spaces. None work properly.Incidentally, if anyone knows an easier way to change the color of a link based on the output from a database, I'm all ears. thanks.

<a href="dictionary.php?o=Shaping+&+The+Deep" <?php if($_GET["o"] === "Shaping & The Deep") echo $theclass;?>>Shaping & The Deep</a>

The other problem I have is odd. I use the script to pull words out of the database for a dictionary. Some of the words have apostraphe's in them. Now, it works fine when it shows up on the page, but I use this snippet so that the <title element changes to show the word that's being shown. On the page it's fine, but up at the top of the browser where the title shows up, there are \ in front of the apostraphe's.. Here's the snippet I use to show the title.

<?php $title="The Shattered Realms :: The Dictionary - $_GET[s]" ?>

And the database query..

$result = mysql_query ("SELECT * FROM dictionary WHERE word = '{$_GET['s']}' ORDER BY word ASC") or die(mysql_error());

Link to comment
Share on other sites

<a href="dictionary.php?o=Shaping+&+The+Deep" <?php if($_GET["o"] === "Shaping & The Deep")?> class="<?php echo $theclass;?>">Shaping & The Deep</a>

might be missing the class= in the html to alter the colour. untested.

stripslashes($_GET[s])

see if a stripslashes will work.

Link to comment
Share on other sites

For the first solution..I actually have the class= stored in the variable. Sorry. Should have mentioned. The code works fine on all the other links, which are single words. So I assume the problem lies in matching the spaces and symbol.Gah. The second solution worked though. That's weird. I was under the impression that the function was strpslashes (without the I). Adding the I made it work. Thanks a lot.EDIT: Nevermind on the second one. I just replaced the & with "and" and replaced the + with spaces in the php. That seems to have worked.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...