|    
			
				14/08/2009, 12:51
			
			
			  | 
  |   |  |  |  Fecha de Ingreso: abril-2009 
						Mensajes: 409
					 Antigüedad: 16 años, 6 meses Puntos: 3 |  | 
  |  Ayuda para pasar bases con apostrofes y Ñ con php  
  Hola a todos tengo una base dfb y la necesito pasar a mysql , tengo el siguiente scrips que anda barbaro, pero tengo el siguiente problemalas Ñ las pasa ¥ con este signo y cuando encuentra un apostrofe "'" automaticamente detiene el scrip y tira error.
 Mi pregunta es : como hago para que pase las Ñ bien y los apostrofes para que no de error.
 gracias, aca pongo el scrip para que lo vean
 
 <?
 $basedbf='sbapropi.dbf';
 $mifile = explode (".",$basedbf);
 
 $based = $mifile[0];
 
 printf($based);
 printf("<br>");
 
 $link = mysql_connect("localhost", "root","chamuyo");
 mysql_select_db("veterinaria", $link);
 
 
 if (($descriptor=dbase_open($basedbf,0))==0)
 {
 printf ("<br>Error al abrir la base de datos");
 }
 else
 {
 $num_registros = dbase_numrecords($descriptor);
 $num_campos = dbase_numfields($descriptor);
 $regcampos = dbase_get_header_info($descriptor);
 
 $cadenasql = "create table " . $based . " ( ";
 $titcampos = "";
 
 for ($j=0;$j<$num_campos -1 ;$j++)
 {
 $cadenasql = $cadenasql . strtolower($regcampos[$j][name]);
 $titcampos = $titcampos . trim(strtolower($regcampos[$j][name])) . ", ";
 if ( strtolower($regcampos[$j][type])=="character" )
 {
 if ( Trim($regcampos[$j][length]) > "20" )
 { $cadenasql = $cadenasql . " varchar(" . $regcampos[$j][length] . "),"; }
 else { $cadenasql = $cadenasql . " char(" . $regcampos[$j][length] . "),";}
 }
 if ( strtolower(trim($regcampos[$j][type]))=="date" )
 {
 $cadenasql = $cadenasql . " datetime,";
 }
 if ( strtolower(trim($regcampos[$j][type]))=="number" )
 {
 if ( Trim($regcampos[$j][precision])=="0")
 { $cadenasql = $cadenasql . " Integer(" . $regcampos[$j][length] . "),";}
 else {$cadenasql = $cadenasql . " decimal (" . $regcampos[$j][length] . ",".$regcampos[$j][precision]."),";}
 }
 }
 $cadenasql = $cadenasql . strtolower($regcampos[$j][name]);
 $titcampos = $titcampos . trim(strtolower($regcampos[$j][name]));
 
 if ( strtolower($regcampos[$j][type])=="character" )
 {
 if ( Trim($regcampos[$j][length]) > "20" )
 { $cadenasql = $cadenasql . " varchar(" . $regcampos[$j][length] . ") )"; }
 else { $cadenasql = $cadenasql . " char(" . $regcampos[$j][length] . ") )";}
 }
 if ( strtolower(trim($regcampos[$j][type]))=="date" )
 {
 $cadenasql = $cadenasql . " datetime ) )";
 }
 if ( strtolower(trim($regcampos[$j][type]))=="number" )
 {
 if ( Trim($regcampos[$j][precision])=="0")
 { $cadenasql = $cadenasql . " Integer(" . $regcampos[$j][length] . ") )";}
 else {$cadenasql = $cadenasql . " decimal (" . $regcampos[$j][length] . ",".$regcampos[$j][precision].") )";}
 }
 
 /* Creando la Tabla */
 
 /* $result = mysql_query($cadenasql, $link); */
 
 /* Insertando los Registros */
 
 for ($i=1;$i<=$num_registros;$i++)
 //for ($i=1;$i<=50 ;$i++)
 {
 $cadenadatos = "" ;
 $registro= dbase_get_record ($descriptor, $i);
 for ($j=0;$j<$num_campos - 1;$j++)
 {
 if ( strtolower(trim($regcampos[$j][type]))=="date" )
 {
 $cadenadatos = $cadenadatos . "'" . (trim($registro[$j])=="" ? "\n" : trim($registro[$j])) . "',";
 }
 if ( strtolower(trim($regcampos[$j][type]))=="character" )
 {
 $cadenadatos = $cadenadatos . "'" . (trim($registro[$j])=="" ? "\n" : trim($registro[$j])) . "',";
 }
 if ( strtolower(trim($regcampos[$j][type]))=="number" )
 {
 $cadenadatos = $cadenadatos . (trim($registro[$j])=="" ? "\n" : trim($registro[$j])) . ",";
 }
 
 }
 if ( strtolower(trim($regcampos[$j][type]))=="date" )
 {
 $cadenadatos = $cadenadatos . "'" . (trim($registro[$j])=="" ? "\n" : trim($registro[$j])) . "'";
 }
 if ( strtolower(trim($regcampos[$j][type]))=="character" )
 {
 $cadenadatos = $cadenadatos . "'" . (trim($registro[$j])=="" ? "\n" : trim($registro[$j])) . "'";
 }
 if ( strtolower(trim($regcampos[$j][type]))=="number" )
 {
 $cadenadatos = $cadenadatos . (trim($registro[$j])=="" ? "\n" : trim($registro[$j])) . "";
 }
 
 $cadenasql = "Insert into " . $based . " (" . $titcampos . ") Values (" . $cadenadatos . ")";
 printf($cadenasql);
 $result = mysql_query($cadenasql, $link) or die ("Invalid query");
 printf("<br>");
 }
 
 dbase_close($descriptor);
 printf ("<br>Base de datos cerrada");
 }
 mysql_close( $link);
 
 ?>
 
 Saludos y espero ayuda.
 
 la base esta en UTF-8 general-ci
     |