You are here: If a field mysql have ', how I can resolve « All PHP « IT news, forums, messages
If a field mysql have ', how I can resolve

Posted by artev on 09/13/06 20:10

I have this query:
$query = SELECT ID, text
FROM table
WHERE ID>100
AND text = ......;


In the field text I want a filter so:
AND mysql_real_escape_string(text) = ......;

because in the text I have words with ' .
-------------------------------------------------------------------------

notice, I not want to do this:
AND text ='".mysql_real_escape_string($text)."'";


because the problem isn't the $text (I have already change with
mysql_real) but is the field text itself;
in the db (with phpmyadmin) I see the words who have ';
but when i recall with query the field text, there aren't more the
words with ' .

for to verify I have do this:
when I extract the field text,I not see more the words with '
(type book's , apple's ...)


$my_test =SELECT text
FROM table
WHERE 1=1;

foreach ($my_test as $my)
{
echo "<script type='text/javascript'>";
echo "alert( '$my->text' )";
echo "</script>";
}


for take out all the words I have make this

foreach ($my_test as $my)
{$new_var=mysql_real_escape_string($my->text);
echo "<script type='text/javascript'>";
echo "alert( '$new_var' )";
echo "</script>";
}

any idea?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация