Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/09/2014, 03:16
Avatar de totti026
totti026
 
Fecha de Ingreso: junio-2011
Mensajes: 150
Antigüedad: 12 años, 10 meses
Puntos: 4
Pregunta error al crear bd con php

Hola que tal,
Tengo este script que me crea una base de datos...
Código PHP:
Ver original
  1. <?php
  2. $bd = $_POST['bd'];
  3. $host = 'localhost';
  4. $user = 'root';
  5. $pass = '';
  6. $conexion = mysql_connect($host,$user,$pass);
  7. mysql_query("SET NAMES UTF8");
  8.  
  9. $sql = "CREATE database $bd DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";                
  10. $inseltar = mysql_query($sql,$conexion);
  11. if(!$inseltar)
  12. {
  13.     echo "Error al crear la bd <strong>$bd</strong>";
  14. }
  15. ?>

Hasta ahí va bien, pero cuando le quiero agregar privilegios...falla y ya no crea la bd.
trate de poner barras invertidas para escapar las comillas pero tampoco.
alguna idea?

Código PHP:
Ver original
  1. $sql = "CREATE database si DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;GRANT ALL PRIVILEGES ON `$bd`.* TO 'usuario'@'localhost';";

Nota: Si tengo creado el "usuario".
Saludos!