php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15668 translation of symbol '&' when storing in Mysql
Submitted: 2002-02-22 02:58 UTC Modified: 2002-02-22 12:48 UTC
From: macolet at goldtelevision dot com Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.0.5 OS: linux redhat 7.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: macolet at goldtelevision dot com
New email:
PHP Version: OS:

 

 [2002-02-22 02:58 UTC] macolet at goldtelevision dot com
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 '&'.




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-22 12:20 UTC] sander@php.net
Can you provide a sample script? You're very likely doing something wrong...
 [2002-02-22 12:35 UTC] macolet at goldtelevision dot com
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;
 [2002-02-22 12:47 UTC] sander@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php

Can't reproduce. 
 [2002-02-22 12:48 UTC] mfischer@php.net
You may want to try a never version anyway, 4.0.6 or 4.1.1 ...
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 20:01:30 2025 UTC