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 ?
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
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
>
>
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
>>
>>
>
>
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!
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!
>
Re: multiple updates
Post removed (X-No-Archive: yes)
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..
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