ID: 15668
Updated by: [EMAIL PROTECTED]
-Summary: translation of symbol '&' when storing in Mysql
Reported By: [EMAIL PROTECTED]
-Status: Feedback
+Status: Open
Bug Type: MySQL related
Operating System: linux redhat 7.1
PHP Version: 4.0.5
New Comment:
the script that causes the problem :
when the string $ragsoc1 contains & in Mysql I found &
$preserve="";
while (strpos($ragsoc1," "))
{
$ragsoc1=str_replace(" "," ",$ragsoc1);
}
// print $ragsoc1;
$ragsoc1=cleanup_text($ragsoc1,$preserve);
$ragsoc2=cleanup_text($ragsoc2,$preserve);
$indir1=cleanup_text($indir1,$preserve);
$indir2=cleanup_text($indir2,$preserve);
$cap=cleanup_text($cap,$preserve);
$citta=cleanup_text($citta,$preserve);
$prov=cleanup_text($prov,$preserve);
$paese=cleanup_text($paese,$preserve);
$telef1=cleanup_text($telef1,$preserve);
$telef2=cleanup_text($telef2,$preserve);
$fax=cleanup_text($fax,$preserve);
$mytext=cleanup_text($mytext,$preserve);
// print $ragsoc1;
// echo '$check1';
session_register("recatt_soc");
if ($recatt_soc==3)
{
$a1="insert into societa
(ragsoc1,ragsoc2,indir1,indir2,cap,citta,prov,paese,";
$b1="telef1,telef2,fax,note) values
('$ragsoc1','$ragsoc2','$indir1','$indir2',";
$c1="'$cap','$citta','$prov','$paese','$telef1','$telef2','$fax','$mytext')";
$where_cat="";
}
else
{
$where_cat="where (IDSOC='$cod')";
$a1="update societa set ragsoc1='$ragsoc1' , ragsoc2='$ragsoc2',
";
$b1="indir1='$indir1', indir2='$indir2', cap='$cap',
citta='$citta', ";
$c1="prov='$prov',paese='$paese', telef1='$telef1',
telef2='$telef2', fax='$fax', note='$mytext' ";
$z1=$where_cat;
}
$query="$a1 $b1 $c1 $where_cat";
// echo $query;
echo "<br>\n";
$result=mysql_query($query)
or die ("Query errata : "
."<li>errorno".mysql_errno()
."<li>error=".mysql_error()
."<li>error=".$query
);
session_register("recatt_soc");
// echo $recatt_soc;
Previous Comments:
------------------------------------------------------------------------
[2002-02-22 12:20:58] [EMAIL PROTECTED]
Can you provide a sample script? You're very likely doing something
wrong...
------------------------------------------------------------------------
[2002-02-22 02:58:56] [EMAIL PROTECTED]
In PHP script I have a variable with a string assigned containing the
symbol '&' :
$myvariable = 'Smith & Sons';
when I insert the variable in the database :
$query="insert into mytable (mycolumn) values
(myvalue1='$myvariable');";
$result=mysql_query($query);
if I edit directly the column in Mysql the symbol '&' has been
translated to '&'.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15668&edit=1