For the life of me, I cannot figure out why this is happening. I tried typecasting I've tried using built-in parsing functions (intval), and I have tried using string replace methods, but no matter what I do, my $AccountNum returns "1"
and after "parsing" it turns into a 0.
I don't have much experience in custom programming on WordPress and am hoping someone here might know where the problem lies. Below is the WordPress page I am trying to implement, and below that is the portion of functions.php that I added on to, which is being implemented, and the last bit is my output.
Please help!
[vc_row][vc_column][vc_column_text][insert_php]
if ($_POST['submit']) {
saveAccountNum($_POST['email'], $_POST['password']);
echo $AccountNum;
get_all_user_info((int)$AccountNum);
}
[/insert_php][/vc_column_text][/vc_column][/vc_row]
part 2 (functions.php script)
function get_all_user_info($AccountNumber){
global $AccountNum;
$dbhost = "localhost";
$dbuser = "#######";
$dbpass = "#######";
$db = "#######";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
echo $AccountNumber;
$userData = "CALL get_all_user_info("+$AccountNumber+")";
$sql = mysqli_query($conn, $userData);
global $First_Name;
if(!$sql){
die("Didn't work, here's why: " . mysql_error());
}
else{
$object = $sql->fetch_object();
$First_Name = $object->First_Name;
echo "All variables made: " .$First_Name;
}
$conn->close();
}
part 3 (output)
Changed variable name: ‘1”1’0All variables made:
As you can see, It doesn't give me any errors, but the error arises when I try to parse from a string to an int. This happens whether I try typecasting, or calling functions, and to be honest, I am out of ideas as to why. Any help would be much appreciated.