multiple updates
am 12.12.2006 15:50:56 von UlyxHow 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 ?
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"
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
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
>
>
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"
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
>>
>>
>
>
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!
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"
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!
>
Post removed (X-No-Archive: yes)
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 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