Re: Insert Query PROBLEMS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- Aaron Todd <aaloki88@xxxxxxxxxxx> wrote:

> I'm trying to run an INSERT query on my mysql database and it isnt
> working.
> 
> Here is the query:
> $updatequery = "UPDATE `users`
>                           SET 
>
('company','fname','lname','address1','address2','city','state','zip','phone','extension','fax','email')
> 
> =
>                                  
>
('".$_POST['company']."','".$_POST['fname']."','".$_POST['lname']."','".$_POST['address1']."','".$_POST['address2']."','".$_POST['city']."','".$_POST['state']."','".$_POST['zip']."','".$_POST['phone']."','".$_POST['extension']."','".$_POST['fax']."','".$_POST['email']."')
>                           WHERE `ID`='".$_GET['record']."'";
> 
> When I echo this it looks fine, but nothing in the database
> reflects the 
> change.  I have tried cutting it down to only the first 2 colums
> and then it 
> works.  But I cant see a syntax error that would cause this not to
> work. 
> Does anyone have any idea why this might not be working.

1-You've got GET and POST mixed together in your query. Is this
intentional?

2-You're using single quotes on the field names. Did you intend to
use ticks?

3-Have you tried pasting the resulting query into either a command
line or admin tool to see if MySQL is choking on something? One thing
that had me pulling out my hair for a few hours was I had NOT NULL on
a field in the DB, and one of the fields being updated was being
populated with a NULL. 

Also, if PHP is not giving you an error message, check your reporting
level to make sure it should be giving you one.

Finally, just a suggestion - you might want to consider rewriting
queries like this to make them more readable:

$updatequery = 
"UPDATE users
SET company   = '".$_POST['company']."',".
    "fname     = '".$_POST['fname']."',".
    "lname     = '".$_POST['lname']."',".
    "address1  = '".$_POST['address1']."',".
    "address2  = '".$_POST['address2']."',".
    "city      = '".$_POST['city']."',".
    "state     = '".$_POST['state']."',".
    "zip       = '".$_POST['zip']."',".
    "phone     = '".$_POST['phone']."',".
    "extension = '".$_POST['extension']."',".
    "fax       = '".$_POST['fax']."',".
    "email     = '".$_POST['email']."'".
"WHERE ID='".$_GET['record']."'";


> 
> Thanks,
> 
> Aaron 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 



=====
Mark Weinstock
mark_weinstock@xxxxxxxxx
***************************************
You can't demand something as a "right" unless you are willing to fight to death to defend everyone else's right to the same thing.
***************************************


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux