multiple updates

multiple updates

am 12.12.2006 15:50:56 von Ulyx

How to update multiple values ?
e.g.
UPDATE user SET name='$name' WHERE id='$id' "

This will update just one field.
How can i update multiple fields ( lastname, city ) on this way ?

Re: multiple updates

am 12.12.2006 16:00:23 von The Eclectic Electric

"ulyx" wrote in message
news:elmfjh$4tr$1@ss408.t-com.hr...
> How to update multiple values ?
> e.g.
> UPDATE user SET name='$name' WHERE id='$id' "
>
> This will update just one field.
> How can i update multiple fields ( lastname, city ) on this way ?
>
>

UPDATE user SET name='value', lastname='value', city='value WHERE id='value

http://dev.mysql.com/doc/

+e

Re: multiple updates

am 12.12.2006 17:20:08 von Ulyx

I have tryed thise before posting, but its not working :-(
----------------------------------------


> UPDATE user SET name='value', lastname='value', city='value WHERE
id='value
>
> http://dev.mysql.com/doc/
>
> +e
>
>

Re: multiple updates

am 12.12.2006 17:37:07 von Sean

How do you populate the query string?

If you are building the string in code ... watch out for quotes in the text
which interfere ...

UPDATE user SET surname = 'O'neil'

Previous poster did miss out a quote
UPDATE user SET name='value', lastname='value',
city='value' WHERE id='value

Perhaps you could post the exact query you have so that we can see....

BTW; make 100% sure that the table and fields are correctly spelt.

Sean


"ulyx" wrote in message
news:elmkuf$i3e$1@ss408.t-com.hr...
>I have tryed thise before posting, but its not working :-(
> ----------------------------------------
>
>
>> UPDATE user SET name='value', lastname='value', city='value WHERE
> id='value
>>
>> http://dev.mysql.com/doc/
>>
>> +e
>>
>>
>
>

Re: multiple updates

am 12.12.2006 17:41:35 von Captain Paralytic

ulyx wrote:
> I have tryed thise before posting, but its not working :-(
> ----------------------------------------
>
>
> > UPDATE user SET name='value', lastname='value', city='value WHERE
> id='value
> >
> > http://dev.mysql.com/doc/
> >
> > +e
> >
> >
I love that "its not working". Well that sure gives us all the
infomation we need to help you, doesn't it!

Does the whole server break? Does the MySQL instance crash? Does
the php code used to access the database crash? Does the SQL simply
return an SQL error? ...


I could go on! We are a helpful bunch, but we are not telepathic.

Please tell us WHAT you are seeing so that we know WHAT to fix!

Re: multiple updates

am 12.12.2006 19:18:01 von Ulyx

Im sorry, you are totaly right... This is the code that im using. I get no
error , but there is no update.
This is standard dreamweaver update and its working very good.

if ((isset($HTTP_POST_VARS["updateUser"])) && ($HTTP_POST_VARS["updateUser"]
== "form"))
{
$updateSQL = sprintf("UPDATE users SET name=%s WHERE id=%s",
GetSQLValueString($HTTP_POST_VARS['name'], "text"),
GetSQLValueString($HTTP_POST_VARS['field_id'],
"text"));
}

If i continue with lastname = '$lastName', city='$city' then nothing happens
but if i want to change just the name part ( just one field ) then its
working perfect..



"Captain Paralytic" wrote in message
news:1165941695.057103.177830@79g2000cws.googlegroups.com...
>
> ulyx wrote:
> > I have tryed thise before posting, but its not working :-(
> > ----------------------------------------
> >
> >
> > > UPDATE user SET name='value', lastname='value', city='value WHERE
> > id='value
> > >
> > > http://dev.mysql.com/doc/
> > >
> > > +e
> > >
> > >
> I love that "its not working". Well that sure gives us all the
> infomation we need to help you, doesn't it!
>
> Does the whole server break? Does the MySQL instance crash? Does
> the php code used to access the database crash? Does the SQL simply
> return an SQL error? ...
>
>
> I could go on! We are a helpful bunch, but we are not telepathic.
>
> Please tell us WHAT you are seeing so that we know WHAT to fix!
>

Re: multiple updates

am 12.12.2006 19:47:48 von unknown

Post removed (X-No-Archive: yes)

Re: multiple updates

am 13.12.2006 14:28:45 von Ulyx

And idea guys ??

------------------------------------------------------------ --------
> Im sorry, you are totaly right... This is the code that im using. I get no
> error , but there is no update.
> This is standard dreamweaver update and its working very good.
>
> if ((isset($HTTP_POST_VARS["updateUser"])) &&
($HTTP_POST_VARS["updateUser"]
> == "form"))
> {
> $updateSQL = sprintf("UPDATE users SET name=%s WHERE id=%s",
> GetSQLValueString($HTTP_POST_VARS['name'], "text"),
> GetSQLValueString($HTTP_POST_VARS['field_id'],
> "text"));
> }
>
> If i continue with lastname = '$lastName', city='$city' then nothing
happens
> but if i want to change just the name part ( just one field ) then its
> working perfect..

Re: multiple updates

am 13.12.2006 14:44:50 von Shion

ulyx wrote:
> Im sorry, you are totaly right... This is the code that im using. I get no
> error , but there is no update.
> This is standard dreamweaver update and its working very good.
>
> if ((isset($HTTP_POST_VARS["updateUser"])) && ($HTTP_POST_VARS["updateUser"]
> == "form"))
> {
> $updateSQL = sprintf("UPDATE users SET name=%s WHERE id=%s",
> GetSQLValueString($HTTP_POST_VARS['name'], "text"),
> GetSQLValueString($HTTP_POST_VARS['field_id'],
> "text"));
> }

How old PHP do you use??

Use $_POST/$_GET/$_REQUEST and not $HTTP_POST_VARS.
Add single quotes around the %s.

Are you sure your $_POST['updateUser'] has the value "form" ?
Does your GetSQLValueString() function work?


--

//Aho