Date: 06/16/02
- Next message: Hannes Wyss: "[PHP-DB] Time Consuming DB-Transaction"
- Previous message: César Aracena: "[PHP-DB] RE: [PHP] Tricky Query <---SOLVED"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To make it easier for yourself to see errors, don't bother concatenating the
string when you don't need to. It makes everything tidier.
You could use this:
$query = "INSERT INTO socios VALUES ('$numsocio', '$nivelsocio',
'$apellido', '$nombre', '$nac1-$nac2-$nac3', '$tipodoc', '$docnum',
'$profesion',
'$cuilcuit1-$cuilcuit2-$cuilcuit3', '$nacionalidad',
'$estcivil', '$domicilio', '$codpostal', '$localidad',
'$provincia', '\($tel1\) $tel2', '\($telemer1\) $telemer2', '\($cell1\)
$cell2', '$email',
'$apellcony', '$nomcony', '$tipodoccony', '$doccony',
'$naccony1-$naccony2-$naccony3', '$empresuc',
'$categoria',
'$fechaingreso1-$fechaingreso2-$fechaingreso3',
'$fechabaja1-$fechabaja2-$fechabaja3')";
Instead of this (what you had):
$query = "INSERT INTO socios VALUES ('".$numsocio."',
'".$nivelsocio."',
'".$apellido."', '".$nombre."', '".$nac1."-".$nac2."-".$nac3."',
'".$tipodoc."', '".$docnum."', '".$profesion."',
'".$cuilcuit1."-".$cuilcuit2."-".$cuilcuit3."', '".$nacionalidad."',
'".$estcivil."', '".$domicilio."', '".$codpostal."', '".$localidad."',
'".$provincia."', '\(".$tel1."\) ".$tel2."', '\(".$telemer1."\)
".$telemer2."', '\(".$cell1."\) ".$cell2."', '".$email."',
'".$apellcony."', '".$nomcony."', '".$tipodoccony."', '".$doccony."',
'".$naccony1."-".$naccony2."-".$naccony3."', '".$empresuc."',
'".$categoria."',
'".$fechaingreso1."-".$fechaingreso2."-".$fechaingreso3."',
'".$fechabaja1."-".$fechabaja2."-".$fechabaja3."')";
Alternatively, you could use an insert function (for mySQL) which makes it
even easier. I have written one, and if ya want, I can send it to ya. All
you would have to write is something like this:
$data = array(
"column1" => "value1",
"column2" => 2,
"column3" => "value3"
);
dbInsert("tableName",$data);
In the function, it also has automatic type checking, so you don't need to
add single quotes around your text values (as you would have to do in a
regular sql query). It doesn't do too much else from that, but you could
program it to, if you needed (such as addslashes(), etc), but as I have
magic quotes turned on, it doesn't affect my situation.
As for your error, I'm not too sure. I don't know if you have to escape the
brackets (as they are inside the string quotes), but try outputting your sql
statement and using command line to test query. Or restructure your sql so
it looks like this:
$query = "INSERT INTO socios SET colname = 'value', col2name = 'value2'";
Adam
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Hannes Wyss: "[PHP-DB] Time Consuming DB-Transaction"
- Previous message: César Aracena: "[PHP-DB] RE: [PHP] Tricky Query <---SOLVED"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

