Comunidad de diseño web y desarrollo en internet online

Ayuda Con Creación De Tabla, Urgente!!!

Citar            
MensajeEscrito el 05 Jun 2008 02:04 am
Hola, yo estube creando un login para mi web, pero cuando pongo para crear la tabla, y pongo el siguiente codigo, me sale un error, claro que yo aca no pongo los datos de mi cuenta, alcaro eso por si hay alguno que no entiende.

$dbhost=\'localhost\';
$dbusername=\'username\';
$dbuserpass=\'password\';
$dbname=\'database\';
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die(\'Cannot select database\');
$query = \'CREATE TABLE users(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
username VARCHAR(30) NOT NULL,
password VARCHAR(20) NOT NULL,
email VARCHAR(40) NOT NULL)\\\';
$result = mysql_query($query);
echo \"!Tabla creada!\";
?>


Cuando pongo ese codigo me sale el siguiente error:

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'$dbhost=\'localhost\'\' at line 1


si alguien me puede ayudar, se lo agradecería.
Saludos

PD: IMPORTANTE LAS BARRITAS /, ME LAS ESTA AGREGANDO EL FORO, CUANDO COPIO Y PEGO EL CODIGO!!!!!

Por lennox

1 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 05 Jun 2008 04:26 am
te sobran los slashes !!!

Por jpcw

Claber

1715 de clabLevel

1 tutorial

Genero:Masculino  

AlgoritmicBrainDesigner

firefox
Citar            
MensajeEscrito el 05 Jun 2008 12:33 pm
Prueba lo siguiente:

Código :


$myCon = mysql_connect($host,$user,$pass);
$myDb = mysql_select_db($database,$myCon);



Y luego continuas con la creación de la tabla.

Por Necrophasto

Claber

148 de clabLevel



Genero:Masculino  

Diseñador gráfico y web

mozilla

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.