justmelat
asked on
how do i add stripslashes to this piece of code in php/mysql application
how do i add the get_magic_quotes_gpc()==1 to the attached code so it will remove the slashes that are in my db. I was able to do this for another section of the code and it works, but i can't figure out how to add it to the array_push and else statement in the code that is attached.
//$R[$row['R_NUMBER']]['AN SWER'][$ro w['Q_ID']] =$row['TEX T'];
$R[$row['R_NUMBER']]['ANSW ER'][$row[ 'Q_ID']]= ((get_magic_quotes_gpc()== 1)?stripsl ashes($row ['TEXT']): $row['TEXT ']);
//$R[$row['R_NUMBER']]['AN
$R[$row['R_NUMBER']]['ANSW
function getRequest($requestNumber,$answerTable='ANSWER')
{
global $db;
$sql = "SELECT * FROM " . $answerTable ." WHERE R_NUMBER='".$requestNumber."' ORDER BY Q_ID";
$result = mysql_query($sql,$db) or die("ERROR: " . mysql_error());
while ( $row = mysql_fetch_assoc($result) )
{
if (preg_match("/\[\]$/", $row['Q_ID'])) //If there is a [] in the ID, it is an array
{
preg_match("/([^\[]+)\[\]/", $row['Q_ID'], $matches); //Split the ID into the number and the []
$arrayname = $matches[1];
if (!is_array($answer[$arrayname]))
{
$answer[$arrayname]=array();
}
array_push($answer[$arrayname],preg_replace("/<br>/",$cr,$row['TEXT']));
} else
{
$answer[$row['Q_ID']] = preg_replace("/<br>/",$cr, $row['TEXT']);
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi routinet: i tried your solution, but still get the slashes, that then can't be removed. the only solution was to remove the addslashes. i don't know what has gone wrong with the new server upgrade, but it has everything off now.
ASKER
just didn't work for my application
>>> tried your solution, but still get the slashes, that then can't be removed
Were you trying to use this to cleanse existing data already in a database? That's not what addslashes() does. This function's purpose is to escape data before adding it to a database.
Were you trying to use this to cleanse existing data already in a database? That's not what addslashes() does. This function's purpose is to escape data before adding it to a database.
;-)
Best to all, ~Ray