Jump to content

mysql update with variable?


Kristian_C
 Share

Recommended Posts

I think that is possible but be alot of extra unneeded code. you would have to run a query to your database to store the field name into your varaible $artikkel before you run the query you just posted. But like i said basicly your sorta doing things twice when you can do it once just by using the field name instead of $artikkel and this putts more overhead on your server. if that makes any sense

Link to comment
Share on other sites

I think that is possible but be alot of extra unneeded code. you would have to run a query to your database to store the field name into your varaible $artikkel before you run the query you just posted. But like i said basicly your sorta doing things twice when you can do it once just by using the field name instead of $artikkel and this putts more overhead on your server. if that makes any sense
Hehe, think i understand, just used the regular update with alot of if's/elseif's insted :) hehe...Thanks->Kristian_C
Link to comment
Share on other sites

The only thing to change would be to enclose all your variables with brackets so that it is clear to PHP. I think the object requires it.mysql_query("UPDATE avis SET {$artikkel}={$edi} AND {$tittel}={$title} WHERE avis={$bruker->avis}'");I noticed you also have an orphaned single quote at the end there. That will be a SQL error.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...