Log in

View Full Version : Hello again to all my friends, my need for help just never ends ^_^


gengar003
08-24-2003, 01:23 AM
Eeh, anyway, I've got a variable, $data, and I want to put it into an <a href="blah bal&data="($data)">

etc, but $data has double/single quotes in it, and ">" and "<" signs... is there any way to get php to add slashes to any non-letter or single quote character?

(actual php code used)

// Okay, now the link to remove it.
$th_rong_named = "<a href=\"tacemon.php?action=give&tacemon=";
//oops! don't have that info yet; better query for the TAC?mon's $th_rite_name.
$th_rong_named .= $th_rite_name;
$th_rong_named .= "&subaction=take&username=";
//ALAS! More info to query for, this time, we need the actual USERNAME. (>.< gotta integrate this more...)
$usernaming_kwery = $DB_site->query_first("SELECT username FROM `user` WHERE userid=$counter");
$username = $usernaming_kwery[username];
$th_rong_named .= $username;
$th_rong_named .= "&catchname=";
$th_rong_named .= $th_rong_name;
$th_rong_named .= "&data=";
//<<<<<<<<<<<<<<<<<<<<<<<Problem start
//$th_rong_named .= $data;
//<<<<<<<<<<<<<<<<<<<<<<<Problem end.
$th_rong_named .= "\">";
$th_rong_named .= $th_rong_name;
$th_rong_named .= "</a>";


NOTE: I KNOW that the line with $data on it is commented out, that's because the script still runs w/out it, and it looks cleaner, but the functionality of that variable is missing...anyway.

filburt1
08-24-2003, 01:45 AM
What do you mean? PHP doesn't care about < or > in code, and simply escape quotes when necessary (add a backslash before them).

gengar003
08-25-2003, 12:33 AM
ah yes, BUT, the $data exists in a mySQL DB, and it is pulled directly from there placed in an <a href=""> tag, and any innate quotes in the data disrupt the tag... I was wondering if there was a way to get php to escape all the quotes in that string.