Seker Posted May 11, 2012 Posted May 11, 2012 Since V1 doesn't come with a stock jail, I've added one in. I've also added columns to the crimes for jail reason and jail time. My problem is, the jail reason isn't updating, no matter what I change it to in the crimeJREASON table. It still keeps saying "Failed a crime," as I had that set as the reason before I started learning about using DB tables. The jail time updates correctly, and I just used another $ to update the reason the same way: if(rand(1, 2) == 1) { print $r['crimeFTEXT']; $jailtime=$r['crimeJTIME']; $jailreason=$r['crimeJREASON']; mysql_query("UPDATE users SET jail=$jailtime WHERE userid=$userid", $c); mysql_query("UPDATE users SET jailreason=$jailreason WHERE userid=$userid", $c); } Any ideas why the reason isn't updating? Quote
Spudinski Posted May 11, 2012 Posted May 11, 2012 Since V1 doesn't come with a stock jail, I've added one in. I've also added columns to the crimes for jail reason and jail time. My problem is, the jail reason isn't updating, no matter what I change it to in the crimeJREASON table. It still keeps saying "Failed a crime," as I had that set as the reason before I started learning about using DB tables. The jail time updates correctly, and I just used another $ to update the reason the same way: if(rand(1, 2) == 1) { print $r['crimeFTEXT']; $jailtime=$r['crimeJTIME']; $jailreason=$r['crimeJREASON']; mysql_query("UPDATE users SET jail=$jailtime WHERE userid=$userid", $c); mysql_query("UPDATE users SET jailreason=$jailreason WHERE userid=$userid", $c); } Any ideas why the reason isn't updating? Strings... You need to enclose them in SQL, i.e. 'I am a string'. Single or double quotes, doesn't matter. You see, the problem with you query is... to break it down: UPDATE users SET jailreason=$jailreason WHERE userid=$userid First, MySQL attempts to update the `jailreason` column, but since there's no value for it, it fails. Effectively, your query parses as: UPDATE users SET jailreason=I am a string WHERE userid=55490 Quote
Seker Posted May 11, 2012 Author Posted May 11, 2012 Ahh makes sense, it being text. It's always the simple things. Thanks for that! Quote
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.