multiple updates

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 ?
Ulyx [ Di, 12 Dezember 2006 15:50 ] [ ID #1565703 ]

Re: multiple updates

"ulyx" <new_one [at] hotmail.com> wrote in message
news:elmfjh$4tr$1 [at] 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
The Eclectic Electric [ Di, 12 Dezember 2006 16:00 ] [ ID #1565704 ]

Re: multiple updates

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
>
>
Ulyx [ Di, 12 Dezember 2006 17:20 ] [ ID #1565706 ]

Re: multiple updates

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" <new_one [at] hotmail.com> wrote in message
news:elmkuf$i3e$1 [at] 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
>>
>>
>
>
Sean [ Di, 12 Dezember 2006 17:37 ] [ ID #1565707 ]

Re: multiple updates

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!
Captain Paralytic [ Di, 12 Dezember 2006 17:41 ] [ ID #1565708 ]

Re: multiple updates

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" <paul_lautman [at] yahoo.com> wrote in message
news:1165941695.057103.177830 [at] 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!
>
Ulyx [ Di, 12 Dezember 2006 19:18 ] [ ID #1565710 ]

Re: multiple updates

Post removed (X-No-Archive: yes)
Notifier Deamon [ Di, 12 Dezember 2006 19:47 ] [ ID #1565711 ]

Re: multiple updates

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..
Ulyx [ Mi, 13 Dezember 2006 14:28 ] [ ID #1566933 ]

Re: multiple updates

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
Shion [ Mi, 13 Dezember 2006 14:44 ] [ ID #1566934 ]
PHP » alt.php.sql » multiple updates

Vorheriges Thema: I get a syntax error when trying to learn code in a quick start guide.
Nächstes Thema: saving and displaying picture in mysql