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;
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
add a comment |
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
all parameters are passed as string. php does not know which data type you expect. You should stick withfilter_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
add a comment |
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
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
php
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 withfilter_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
add a comment |
all parameters are passed as string. php does not know which data type you expect. You should stick withfilter_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
add a comment |
2 Answers
2
active
oldest
votes
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.
add a comment |
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)){
is_numeric
also recognizes float
– kuh-chan
Mar 24 at 10:15
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Mar 24 at 10:09
DaveDave
3,09291932
3,09291932
add a comment |
add a comment |
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)){
is_numeric
also recognizes float
– kuh-chan
Mar 24 at 10:15
add a comment |
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)){
is_numeric
also recognizes float
– kuh-chan
Mar 24 at 10:15
add a comment |
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)){
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)){
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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