Jump to content

PHP subtraction error


strategos

Recommended Posts

This should be simple. However, when I run the script and input a say 18 char long string, it still returns -10. The variable char_total is accurately capturing the string length.

 

<?php

$inputid = $_POST['steamid'];

$steam_prefix = substr($inputid, 0, 10);

$prefix_length = 10;

$steam_suffixchars = ($char_total - $prefix_length);

$char_total = strlen($inputid);

if($char_total > 25 || $char_total < 11)
$char_valid = false;
else
$char_valid = true;


if($steam_prefix === "STEAM_0:1:" || $steam_prefix === "STEAM_0:0:")
$prefix_check = true;
elseif($steam_prefix != "STEAM_0:1:" || $steam_prefix != "STEAM_0:0:")
$prefix_check = false;

echo "$steam_suffixchars"


?>

Link to comment
Share on other sites

if you know the prefix is a fixed length, why wouldn't you just check what the user inputs?

 

I need to check with prefix to see if it is valid then check the suffix which only consists of inegers. After I get the subtraction right, I was going to run substr() to compare the suffix with is_int()

Link to comment
Share on other sites

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.