stuckwithcode Posted January 6, 2011 Share Posted January 6, 2011 why does this not work $name = "john"; mysql_query("UPDATE table SET user = '$name'text WHERE id = '5'"); how can i get the query to insert the variable and the text eg johntext into the table Quote Link to comment https://forums.phpfreaks.com/topic/223565-really-anoying-help-can-it-be-done/ Share on other sites More sharing options...
merylvingien Posted January 6, 2011 Share Posted January 6, 2011 Can you clarify what you are trying to do? You want to update the user table with the $name variable. I get that, but whats "text"? Is text another variable? Quote Link to comment https://forums.phpfreaks.com/topic/223565-really-anoying-help-can-it-be-done/#findComment-1155645 Share on other sites More sharing options...
stuckwithcode Posted January 6, 2011 Author Share Posted January 6, 2011 no text is just some text that i want to be added to the end of the varaible Quote Link to comment https://forums.phpfreaks.com/topic/223565-really-anoying-help-can-it-be-done/#findComment-1155646 Share on other sites More sharing options...
litebearer Posted January 6, 2011 Share Posted January 6, 2011 then use $new_var = $var1 . $var2 before you update Quote Link to comment https://forums.phpfreaks.com/topic/223565-really-anoying-help-can-it-be-done/#findComment-1155647 Share on other sites More sharing options...
stuckwithcode Posted January 6, 2011 Author Share Posted January 6, 2011 I understand that method but was wondering if you can do it in the one line Quote Link to comment https://forums.phpfreaks.com/topic/223565-really-anoying-help-can-it-be-done/#findComment-1155654 Share on other sites More sharing options...
trq Posted January 6, 2011 Share Posted January 6, 2011 mysql_query("UPDATE table SET user = '{$name}text' WHERE id = '5'"); Quote Link to comment https://forums.phpfreaks.com/topic/223565-really-anoying-help-can-it-be-done/#findComment-1155657 Share on other sites More sharing options...
stuckwithcode Posted January 6, 2011 Author Share Posted January 6, 2011 that did it, cheers buddy Quote Link to comment https://forums.phpfreaks.com/topic/223565-really-anoying-help-can-it-be-done/#findComment-1155659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.