c_shelswell Posted December 29, 2006 Share Posted December 29, 2006 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 Link to comment https://forums.phpfreaks.com/topic/32208-problem-with-get_magic_quote-and-addslashes/ Share on other sites More sharing options...
c_shelswell Posted December 29, 2006 Author Share Posted December 29, 2006 sorry seem to have sorted it i just change the first line toif ((get_magic_quotes_gpc()) == 0)cheers Link to comment https://forums.phpfreaks.com/topic/32208-problem-with-get_magic_quote-and-addslashes/#findComment-149501 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.