Monk3h Posted April 26, 2008 Share Posted April 26, 2008 if ($step == upgrade) { if ($stat[bank] < $bankmin) { Print "You do not have the required funds in your account to Upgrade! Please transfer the required funds!"; }else{ mysql_query("update players set bankaccount=$newbank[name] where id=$stat[id]"); Print "You have successfully upgraded your account to our $newbank[name]"; }} Can anyone tell me why this isnt working? Its displaying the text when i upgrade saying iv upgraded. But it dosnt change the bankaccount feild in Players to the new Bank account. :s Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/ Share on other sites More sharing options...
moselkady Posted April 26, 2008 Share Posted April 26, 2008 You should enclose array elements in braces if you use them within a string. Try changing your sql to the following and see how it goes: mysql_query("update players set bankaccount={$newbank['name']} where id={$stat['id']}"); Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-527988 Share on other sites More sharing options...
Monk3h Posted April 26, 2008 Author Share Posted April 26, 2008 Done.. Still not Working. Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-528027 Share on other sites More sharing options...
hitman6003 Posted April 26, 2008 Share Posted April 26, 2008 Whenever you are having problems with a query there should always be two things you do before anything else... 1) echo out your query... $query = "update players set bankaccount=$newbank[name] where id=$stat[id]"; echo $query; mysql_query($query); 2) show the mysql error(s)... $query = "update players set bankaccount=$newbank[name] where id=$stat[id]"; echo $query; mysql_query($query) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-528035 Share on other sites More sharing options...
Monk3h Posted April 26, 2008 Author Share Posted April 26, 2008 update players set bankaccount=Bronze Account where id=2You have successfully upgraded your account to our Bronze Account So that should work. Thats exactly what i want it to do.. WTF!? Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-528036 Share on other sites More sharing options...
Monk3h Posted April 26, 2008 Author Share Posted April 26, 2008 Could it have somthing to do with the account name having a spcae in it? Do i need to use a diferent Query? Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-528039 Share on other sites More sharing options...
hitman6003 Posted April 26, 2008 Share Posted April 26, 2008 A string must be quoted in an sql query... bankaccount='Bronze Account' Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-528041 Share on other sites More sharing options...
MadTechie Posted April 27, 2008 Share Posted April 27, 2008 try $query = "update players set bankaccount='{$newbank['name']}' where id={$stat['id']}"; mysql_query($query) or die($query.mysql_error()); Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-528044 Share on other sites More sharing options...
Monk3h Posted April 27, 2008 Author Share Posted April 27, 2008 Thanks guys, i added in the '/' and it works now. XD Link to comment https://forums.phpfreaks.com/topic/103081-mysql-update-not-working/#findComment-528049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.