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

  • Home
  • SEARCH
  • 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 6583377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:24:03+00:00 2026-05-25T16:24:03+00:00

My query keeps failing to fetch. It works just fine in my SQL Console

  • 0

My query keeps failing to fetch. It works just fine in my SQL Console so I’m at a loss. Here’s the code.

$q_st = "SELECT tryouts.playerFName,tryouts.playerLName,tryouts.mainEmail,
tryouts.secondEmail, players.number FROM tryouts LEFT JOIN players ON
players.userID=tryouts.userID WHERE players.team = ? 
ORDER BY tryouts.playerLName";

$stmt = $GLOBALS['m']->prepare($q_st);
$stmt->bind_param("s",$GLOBALS['c_team']);
$stmt->execute();
$stmt->bind_result($pfn,$pln,$em,$em2,$num);

if($stmt->fetch()==false)
{
echo($GLOBALS['m']->error . $GLOBALS['m']->sqlstate ." Haha It doesn't work and YOU     don't know why!!!");
}
else
{
while($stmt->fetch())                  {
static $count3;
echo ($pfn . " " . $pln . " " . $num . "<input type=\"checkbox\" class=\"player\" value=\"" . $em ."\"  id=\"player ". ++$count3 . "\"><br />");
}              
}

Result is “00000 Haha It doesn’t work and YOU don’t know why!!!”

I’ve tested all the other stmt parameters and they all come through with success.
Any ideas?

  • 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-05-25T16:24:03+00:00Added an answer on May 25, 2026 at 4:24 pm

    As the mysqli_stmt_fetch() method can return null and false you have to use === to check if the returned value is false or not (or if it is null or not). Otherwise you interpret the return value null as an error code, which it isn’t.

    Additionally your code reads one row from the result with your first fetch() call, but you don’t handle the returned row in any way. You are dropping the first row of your result set which might not be something you want.

    If you want to know how many rows the result set has use mysqli_stmt_num_rows.

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

Sidebar

Related Questions

Here is my MySQL Query that im trying to execute. it keeps failing with
I'm trying to get data from two tables. Here is my code: select p.nim,
I am writing PHP code for a dynamic web page. The SQL query code
This query keeps failing with Integrity constraint violation: 1048 Column 'login_name' cannot be null
I've got a simple SQL query that keeps throwing an SQL syntax error. It
I have prepared a query but it keeps throwing errors. Here is my query:
My application keeps running into Timeout Expired SqlExceptions. The thing is that this query
Query: SELECT DISTINCT ([Equipment List].ID) AS Expr1, [Job Assignments].Job FROM [Equipment List] LEFT JOIN
Query query = getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery( select proj_employee.employee_no as employeeNo, ... .setResultTransformer(Transformers.aliasToBean(User.class)); Inside User.class does the
So I've got a query that keeps deadlocking on me. People who know the

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.