INSERT not working

Hey experts, I have a problem with a INSERT command.

I already checked my field names in my database.
I tried to echo out all fields and everything is working fine.

I don't know why my query is not working....any ideas?  
<?php
 
$salvatd = "INSERT INTO garotas (nome, telefone, idade, cidade, tipo, peso, busto, altura, foto1, foto2, foto3, ensaio, plano, lembrete, nomecompleto, nascimento, rg, termo1, termo2, data, login.id) VALUES ('$nome', '$tel', '$idade', '$cidade', '$tipo', '$peso', '$busto', '$altura', '$fotocapa', '$foto2', '$foto3', '$fazerensaio', '$plano', '$lembrete', '$nomecompleto', '$nascidaem', '$rg', '$leutermos','$infoverdadeira','$data','$usuario')";
								mysql_query($salvatd);
									if(mysql_affected_rows() > 0 ){
										echo "<div class=\"rosa\"><b>success</b></div>";
										exit;
									}else{
										echo "<font color=red><b>Error, try again</b></font>";
										echo "<br>Se este erro persistir, entre em contato conosco através do link <i>Suporte/Ajuda</i> no menu ao lado.";
										exit;
									}
?>

Open in new window

fackzAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

itzdarcCommented:
Make sure your variables don't have the ' character in them... if they do, they should be escaped b/c it will mess with the matching in SQL.  Example:  If $tel = "234'1233", the SQL will write ", '234'1233' " which would generate an error.  Try replacing ' in any of your variables with \'

I'd also try putting ` around the column names and tables name -- you don't know if you've used a reserved word.  ones i'd definitely add them to are data and login.id.  i'd make them

`data` and `login`.`id`

I'd also double check to make sure the user you're connecting to the DB as has access to insert records, but i'm assuming you already did that step.
0
syedasimmeesaqCommented:
try this
<?php
 
$salvatd = "INSERT INTO garotas (nome, telefone, idade, cidade, tipo, peso, busto, altura, foto1, foto2, foto3, ensaio, plano, lembrete, nomecompleto, nascimento, rg, termo1, termo2, data, login.id) VALUES 
 
('".$nome."', '".$tel."', '".$idade."', '".$cidade."', '".$tipo."', '".$peso."', '".$busto."', '".$altura."', '".$fotocapa."', '".$foto2."', '".$foto3."', '".$fazerensaio."', '".$plano."', '".$lembrete."', '".$nomecompleto."', '".$nascidaem."', '".$rg."', '".$leutermos."','".$infoverdadeira."','".$data."','".$usuario."')";
								mysql_query($salvatd);
									if(mysql_affected_rows() > 0 ){
										echo "<div class=\"rosa\"><b>success</b></div>";
										exit;
									}else{
										echo "<font color=red><b>Error, try again</b></font>";
										echo "<br>Se este erro persistir, entre em contato conosco através do link <i>Suporte/Ajuda</i> no menu ao lado.";
										exit;
									}
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.