Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7797389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:40:02+00:00 2026-06-01T23:40:02+00:00

My array would only get a 0 or a 1. I’m using PDO statement

  • 0

My array would only get a 0 or a 1. I’m using PDO statement for mysql, and this is what I have

$result = $fetching -> fetch();
$first_result = $result[0];

if($first_result === 0){
//do something...
}else{
echo "testing";
}

I’m always getting the testing no matter what, if its 0 or not. I’ve echoed out the $first_result[0] for testing purposes and it will tell me what the value is. So I know that the value will shoot out either 0 or not 0. But when it is 0, it still echos out testing.

Help please?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T23:40:04+00:00Added an answer on June 1, 2026 at 11:40 pm

    First of all try to put == not type equivalence. And Second I always use this to check if there any record:

    $q = $pdo->prepare('Your SQL');
    $result = $q->execute($params);
    $rows = $q->fetchAll(PDO::FETCH_ASSOC);
    if (!count($rows) || !$result)
    {
        echo 'No rows or error';
        // To output error $pdo->errorInfo();
    }
    else
    {
        $el = $row[0];
    }
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array which contains another array Would I notate it this way?
I'm not sure how difficult this but I have an array and would like
I have an array that I would like to sort using a date field
I am fetching an array and I would like to assign attributes of items
I have an SHA-1 byte array that I would like to use in a
I have a very large multidimensional array and I would like to sort it
This would be an Array of data: $array = array(sad,bow,blabla); IF $input = I
how would you convert this array: Array ( [0] => Array ( [Contact] =>
The url would be something like this: www.example.com/index.php?file=myFile.ext The filtering would only allow leters
I am trying to understand how a single and multidimensional javascript array would appear

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.