Jump to content

Recommended Posts

I have this code inside a php file and I was wondering if I wrote it the right way, since I'm not quite sure how to check the opposite of something (like a Boolean - true/false):

if (! @is_numeric($pkills)) {
echo( "$pkills is an improper value for kills");
exit();
}

Link to comment
https://forums.phpfreaks.com/topic/119150-solved-simple-noob-question/
Share on other sites

Accomplishes the same thing.  But you don't always want to kill the script for something like that (especially a form).  That was directed at the thread starter btw.

 

P.S: I finally got around to making an avatar for this forum.  Wonderful, right? xD

 

EDIT: Someone noticed.  Sick.

 

 

Thanks again, I'm very knew to PHP so I'm not sure about to best practices for writing the code. The code is just for a small game I'm making with Flash CS3, when the game ends, the user can submit their score (after writing their name), and I just want to make sure the data received by the php script for kills is actually a numeric string and hasn't been tampered with. So, obviously, if the data for kills isn't actually a number, then I want the script to stop and not insert the data into my database table (mySQL).

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.