cant progress with php 5 integer passing from a pageDeleting an element from an array in PHPSend email using the GMail SMTP server from a PHP pagePHP Pass variable to next pageConverting an integer to a string in PHPReturning JSON from a PHP ScriptPassing NULL from PHP to MySQL for auto incrementmysqli: PHP Fatal error: Call to a member function fetch_array()How to pass variables and data from PHP to JavaScript?PHP randomly decrements large integers by 1how to get the value from database to textbox in php

Why do Russians call their women expensive ("дорогая")?

Could I be denied entry into Ireland due to medical and police situations during a previous UK visit?

Preserving culinary oils

Different PCB color ( is it different material? )

Can an old DSLR be upgraded to match modern smartphone image quality

How to properly maintain eye contact with people that have distinctive facial features?

In what episode of TOS did a character on the bridge make a comment about raising the number 1 to some power?

What is the 中 in ダウンロード中?

Asking bank to reduce APR instead of increasing credit limit

Can you move on your turn, and then use the Ready Action to move again on another creature's turn?

How to prevent bad sectors?

Modern approach to radio buttons

Expenditure in Poland - Forex doesn't have Zloty

Do creatures all have the same statistics upon being reanimated via the Animate Dead spell?

Looking after a wayward brother in mother's will

Rotated Position of Integers

How old was this woman (from Tomb of Annihilation) at her death?

The deliberate use of misleading terminology

What was this black-and-white film set in the Arctic or Antarctic where the monster/alien gets fried in the end?

Lunar orbital rendezvous

Fastest way to perform complex search on pandas dataframe

Possible nonclassical ion from a bicyclic system

Beginner's snake game using PyGame

What is game ban VS VAC ban in steam?



cant progress with php 5 integer passing from a page


Deleting an element from an array in PHPSend email using the GMail SMTP server from a PHP pagePHP Pass variable to next pageConverting an integer to a string in PHPReturning JSON from a PHP ScriptPassing NULL from PHP to MySQL for auto incrementmysqli: PHP Fatal error: Call to a member function fetch_array()How to pass variables and data from PHP to JavaScript?PHP randomly decrements large integers by 1how to get the value from database to textbox in php






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















is_int in php 5 doesn't recognize a GET integer when it's passed to it



$blog_ident=$_GET['blog_id'];

if (is_int($blog_ident))

$sql="SELECT * FROM blog WHERE blog_id='$blog_id'";
$result = mysqli_query($db,$sql);

if (!$result)
die('Sorry there was a problem reading the blog.');


// If we get a result back
while ( $row = $result->fetch_array(MYSQLI_ASSOC) )
@extract($row);

else
die ('Problem with the blog');




http://mydomain/blog_edit.php?blog_id=1




This always ends in 'Problem with the blog'. I can't get it to recognize the 1 as an int and proceed to the database query










share|improve this question
























  • all parameters are passed as string. php does not know which data type you expect. You should stick with filter_var - php.net/manual/en/function.filter-var.php

    – kuh-chan
    Mar 24 at 10:08











  • and btw - you should upgrade to a newer version (e.g. 7.3)

    – kuh-chan
    Mar 24 at 10:09











  • your code is wide open to SQL injection attacks - use parameterised statements, or tell your users in advance that their data has been breached - because it will be.

    – Franz Gleichmann
    Mar 24 at 10:48

















0















is_int in php 5 doesn't recognize a GET integer when it's passed to it



$blog_ident=$_GET['blog_id'];

if (is_int($blog_ident))

$sql="SELECT * FROM blog WHERE blog_id='$blog_id'";
$result = mysqli_query($db,$sql);

if (!$result)
die('Sorry there was a problem reading the blog.');


// If we get a result back
while ( $row = $result->fetch_array(MYSQLI_ASSOC) )
@extract($row);

else
die ('Problem with the blog');




http://mydomain/blog_edit.php?blog_id=1




This always ends in 'Problem with the blog'. I can't get it to recognize the 1 as an int and proceed to the database query










share|improve this question
























  • all parameters are passed as string. php does not know which data type you expect. You should stick with filter_var - php.net/manual/en/function.filter-var.php

    – kuh-chan
    Mar 24 at 10:08











  • and btw - you should upgrade to a newer version (e.g. 7.3)

    – kuh-chan
    Mar 24 at 10:09











  • your code is wide open to SQL injection attacks - use parameterised statements, or tell your users in advance that their data has been breached - because it will be.

    – Franz Gleichmann
    Mar 24 at 10:48













0












0








0








is_int in php 5 doesn't recognize a GET integer when it's passed to it



$blog_ident=$_GET['blog_id'];

if (is_int($blog_ident))

$sql="SELECT * FROM blog WHERE blog_id='$blog_id'";
$result = mysqli_query($db,$sql);

if (!$result)
die('Sorry there was a problem reading the blog.');


// If we get a result back
while ( $row = $result->fetch_array(MYSQLI_ASSOC) )
@extract($row);

else
die ('Problem with the blog');




http://mydomain/blog_edit.php?blog_id=1




This always ends in 'Problem with the blog'. I can't get it to recognize the 1 as an int and proceed to the database query










share|improve this question
















is_int in php 5 doesn't recognize a GET integer when it's passed to it



$blog_ident=$_GET['blog_id'];

if (is_int($blog_ident))

$sql="SELECT * FROM blog WHERE blog_id='$blog_id'";
$result = mysqli_query($db,$sql);

if (!$result)
die('Sorry there was a problem reading the blog.');


// If we get a result back
while ( $row = $result->fetch_array(MYSQLI_ASSOC) )
@extract($row);

else
die ('Problem with the blog');




http://mydomain/blog_edit.php?blog_id=1




This always ends in 'Problem with the blog'. I can't get it to recognize the 1 as an int and proceed to the database query







php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 10:13









Johan

2,5681719




2,5681719










asked Mar 24 at 10:02









user3046711user3046711

53




53












  • all parameters are passed as string. php does not know which data type you expect. You should stick with filter_var - php.net/manual/en/function.filter-var.php

    – kuh-chan
    Mar 24 at 10:08











  • and btw - you should upgrade to a newer version (e.g. 7.3)

    – kuh-chan
    Mar 24 at 10:09











  • your code is wide open to SQL injection attacks - use parameterised statements, or tell your users in advance that their data has been breached - because it will be.

    – Franz Gleichmann
    Mar 24 at 10:48

















  • all parameters are passed as string. php does not know which data type you expect. You should stick with filter_var - php.net/manual/en/function.filter-var.php

    – kuh-chan
    Mar 24 at 10:08











  • and btw - you should upgrade to a newer version (e.g. 7.3)

    – kuh-chan
    Mar 24 at 10:09











  • your code is wide open to SQL injection attacks - use parameterised statements, or tell your users in advance that their data has been breached - because it will be.

    – Franz Gleichmann
    Mar 24 at 10:48
















all parameters are passed as string. php does not know which data type you expect. You should stick with filter_var - php.net/manual/en/function.filter-var.php

– kuh-chan
Mar 24 at 10:08





all parameters are passed as string. php does not know which data type you expect. You should stick with filter_var - php.net/manual/en/function.filter-var.php

– kuh-chan
Mar 24 at 10:08













and btw - you should upgrade to a newer version (e.g. 7.3)

– kuh-chan
Mar 24 at 10:09





and btw - you should upgrade to a newer version (e.g. 7.3)

– kuh-chan
Mar 24 at 10:09













your code is wide open to SQL injection attacks - use parameterised statements, or tell your users in advance that their data has been breached - because it will be.

– Franz Gleichmann
Mar 24 at 10:48





your code is wide open to SQL injection attacks - use parameterised statements, or tell your users in advance that their data has been breached - because it will be.

– Franz Gleichmann
Mar 24 at 10:48












2 Answers
2






active

oldest

votes


















1














Values in the $_GET and $_POST super globals are always strings. You may either cast it as an INT or use is_numeric to see if the value is a number.






share|improve this answer






























    0














    The problem is in the second line of code, more specifically is_int(...). The docs page for is_int states its functionality as the following:




    Find whether the type of a variable is integer




    The problem here is that the type of $blog_ident is a string even though the value is a number, because the contents of $_GET is always of the type string. is_int only checks the type of the variable, not its content. If you continue to read on the docs page for is_int you'll find this part.




    To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().




    If you replace is_int($blog_ident) line to the following you should ger the desired result:



    if (is_numeric($blog_ident)){





    share|improve this answer

























    • is_numeric also recognizes float

      – kuh-chan
      Mar 24 at 10:15











    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322612%2fcant-progress-with-php-5-integer-passing-from-a-page%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Values in the $_GET and $_POST super globals are always strings. You may either cast it as an INT or use is_numeric to see if the value is a number.






    share|improve this answer



























      1














      Values in the $_GET and $_POST super globals are always strings. You may either cast it as an INT or use is_numeric to see if the value is a number.






      share|improve this answer

























        1












        1








        1







        Values in the $_GET and $_POST super globals are always strings. You may either cast it as an INT or use is_numeric to see if the value is a number.






        share|improve this answer













        Values in the $_GET and $_POST super globals are always strings. You may either cast it as an INT or use is_numeric to see if the value is a number.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 10:09









        DaveDave

        3,09291932




        3,09291932























            0














            The problem is in the second line of code, more specifically is_int(...). The docs page for is_int states its functionality as the following:




            Find whether the type of a variable is integer




            The problem here is that the type of $blog_ident is a string even though the value is a number, because the contents of $_GET is always of the type string. is_int only checks the type of the variable, not its content. If you continue to read on the docs page for is_int you'll find this part.




            To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().




            If you replace is_int($blog_ident) line to the following you should ger the desired result:



            if (is_numeric($blog_ident)){





            share|improve this answer

























            • is_numeric also recognizes float

              – kuh-chan
              Mar 24 at 10:15















            0














            The problem is in the second line of code, more specifically is_int(...). The docs page for is_int states its functionality as the following:




            Find whether the type of a variable is integer




            The problem here is that the type of $blog_ident is a string even though the value is a number, because the contents of $_GET is always of the type string. is_int only checks the type of the variable, not its content. If you continue to read on the docs page for is_int you'll find this part.




            To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().




            If you replace is_int($blog_ident) line to the following you should ger the desired result:



            if (is_numeric($blog_ident)){





            share|improve this answer

























            • is_numeric also recognizes float

              – kuh-chan
              Mar 24 at 10:15













            0












            0








            0







            The problem is in the second line of code, more specifically is_int(...). The docs page for is_int states its functionality as the following:




            Find whether the type of a variable is integer




            The problem here is that the type of $blog_ident is a string even though the value is a number, because the contents of $_GET is always of the type string. is_int only checks the type of the variable, not its content. If you continue to read on the docs page for is_int you'll find this part.




            To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().




            If you replace is_int($blog_ident) line to the following you should ger the desired result:



            if (is_numeric($blog_ident)){





            share|improve this answer















            The problem is in the second line of code, more specifically is_int(...). The docs page for is_int states its functionality as the following:




            Find whether the type of a variable is integer




            The problem here is that the type of $blog_ident is a string even though the value is a number, because the contents of $_GET is always of the type string. is_int only checks the type of the variable, not its content. If you continue to read on the docs page for is_int you'll find this part.




            To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().




            If you replace is_int($blog_ident) line to the following you should ger the desired result:



            if (is_numeric($blog_ident)){






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 24 at 10:15

























            answered Mar 24 at 10:10









            JohanJohan

            2,5681719




            2,5681719












            • is_numeric also recognizes float

              – kuh-chan
              Mar 24 at 10:15

















            • is_numeric also recognizes float

              – kuh-chan
              Mar 24 at 10:15
















            is_numeric also recognizes float

            – kuh-chan
            Mar 24 at 10:15





            is_numeric also recognizes float

            – kuh-chan
            Mar 24 at 10:15

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322612%2fcant-progress-with-php-5-integer-passing-from-a-page%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript