Jump to content

problem with get_magic_quote and addslashes


c_shelswell

Recommended Posts

Seem to be having a problem with get_magic_quotes. What seems to be happening is that if i add a strange char in to my text field i can't add it to my database. The query works fine if there's no funny chars though. I'm using MySql version 4 and PHP 4 if that makes a difference.

my code is [code]
if (!(get_magic_quotes_gpc()))
{
for ($j=0; $j<=$i; $j++)
{
$files[] = ($_POST_DATA['upfile_'.$j.'']);
$titles[] = addslashes($_POST_DATA['title'.$j.'']);
$prices[] = (number_format($_POST_DATA['price'.$j.''], 2));
$desc[] = nl2br(addslashes($_POST_DATA['desc'.$j.'']));
$info[] = nl2br(addslashes($_POST_DATA['info'.$j.'']));
}
}
else
{
for ($j=0; $j<=$i; $j++)
{
$files[] = ($_POST_DATA['upfile_'.$j.'']);
$titles[] = ($_POST_DATA['title'.$j.'']);
echo ($_POST_DATA['title'.$j.'']).'<br />';
$prices[] = (number_format($_POST_DATA['price'.$j.''], 2));
$desc[] = nl2br($_POST_DATA['desc'.$j.'']);
$info[] = nl2br($_POST_DATA['info'.$j.'']);
}
}

//add to database
$date = date('Y-m-d');
if ($i>1){($i /= 2)-1;}
$addt = 1;
$addo =0;


$conn = db_connect();

for ($add=0; $add<$i; $add++)
{
if ($add > 0)
{
$addo = $addo + 2;
$addt = $addt + 2;
}
$query = "insert into media values ('', '$date', '$files[$addt]', '$titles[$add]', $prices[$add],
'$desc[$add]', '$info[$add]', 1, '$files[$addo]')";

$result = mysql_query($query);

}
[/code]

any help would be fantastic cheers

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.