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
https://forums.phpfreaks.com/topic/255200-php-subtraction-error/
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()

Archived

This topic is now archived and is closed to further replies.

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