database is always as empty as my brain...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Locked
Perfidus
Forum Contributor
Posts: 114
Joined: Sun Nov 02, 2003 9:54 pm

database is always as empty as my brain...

Post by Perfidus »

OK, what you will see next is not a programming jewell, every suggestion is welcome cause I'm new at PHP. By the way, what is happening is that I have a form that calls this stupid php, when I process the form I've get back the message in the echo line (That's nice) but the database is always as empty as my brain.
Any help?

Code: Select all

<?php
<?php 
$link = mysql_connect('mysql.gestionar.info', 'aa1126', 'kindra'); 
mysql_selectdb("aa3968",$link); 
$sql = "INSERT INTO DatosInmueble ( Modo, Localidad, Zona, Dirección, Habitaciones, Banyos, Superficie, Precio, Descripcion, Gas, Aire_Acond, Pta_Blindada, Ascensor, Garaje, Trastero, Calefaccion, Terraza, Armarios, Balcon, Piscina, cocinael, cocinagas, lavavajillas, cafetera, microhondas, horno, zonajuegos, basket, futbol, tenis, accesplaya, minusvalidos, tele, parabolica, video, equipomus, cajafuerte, tranquilo, entornoint, zonacomer, zonaocionoc, calific, tren, carretera, aeropuerto, iglesia, todoelagno, masde1, masde2, metrosplaya, metroscentro, alarma, toilet)" + 
"VALUES ('$Modo', '$Localidad', '$Zona', '$Dirección', '$Habitaciones', '$Banyos', '$Superficie', '$Precio', '$Descripcion', '$Gas', '$Aire_Acond', '$Pta_Blindada', '$Ascensor', '$Garaje', '$Trastero', '$Calefaccion', '$Terraza', '$Armarios', '$Balcon', '$Piscina', '$cocinael', '$cocinagas', '$lavavajillas', '$cafetera', '$microhondas', '$horno', '$zonajuegos', '$basket', '$futbol', '$tenis', '$accesplaya', '$minusvalidos', '$tele', '$parabolica', '$video', '$equipomus', '$cajafuerte', '$tranquilo', '$entornoint', '$zonacomer', '$zonaocionoc', '$calific', '$tren', '$carretera', '$aeropuerto', '$iglesia', '$todoelagno', '$masde1', '$masde2', '$metrosplaya', '$metroscentro', '$alarma', '$toilet')"; 
$result = mysql_query($sql); 
echo "¡Gracias! Hemos recibido sus datos.\n"; 
?> 
?>
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Code: Select all

mysql_selectdb("aa3968",$link);
should be

Code: Select all

mysql_select_db("aa3968",$link);
also add some error handling to the result:

Code: Select all

$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
Mac
Perfidus
Forum Contributor
Posts: 114
Joined: Sun Nov 02, 2003 9:54 pm

At least it changes!!

Post by Perfidus »

Ok, now at least I have some reaction:

You have an error in your SQL syntax near '0' at line 1
0
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Just noticed - you're using a + to concenate, whereas PHP uses a period (.). Try changing:

Code: Select all

toilet)" +
"VALUES
to

Code: Select all

toilet)" .
"VALUES
Mac
Perfidus
Forum Contributor
Posts: 114
Joined: Sun Nov 02, 2003 9:54 pm

Any hints about what's going on?

Post by Perfidus »

Iws this new mistake on the php I posted below or in the form, or where?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Topic continued here:
viewtopic.php?t=14234&view=next
Locked