Jump to content
MakeWebGames

Recommended Posts

Posted

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?

Posted
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

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...