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 553215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:34:54+00:00 2026-05-13T11:34:54+00:00

I’m using php to fetch some records from my db and it keeps returning

  • 0

I’m using php to fetch some records from my db and it keeps returning “No results found”. But, when I print the query to the screen and copy and paste it at the mysql prompt, I get 1 row. Granted, it’s a monster query, but shouldn’t I get the same results? What causes that to happen? Any suggestions on what to check?

Don’t know if it’s helpful, but here’s the query:

$q = db_query("SELECT node.nid AS nid, gallery.field_attach_gallery_value AS gallery, 
node.type AS type, node.vid AS vid, ce.field_brochure_link_url AS ce_brochure_url, 
ce.field_brochure_link_title AS ce_brochure_title, 
ce.field_brochure_link_attributes AS ce_brochure_attributes, 
location.field_location_value AS location_field_location_value, 
ce.field_ongoing_value AS ce_field_ongoing_value, 
ce.field_poster_link_url AS ce_poster_url, 
ce.field_poster_link_title AS ce_poster_title, 
ce.field_poster_link_attributes AS ce_poster_attributes, 
ce.field_press_release_link_url AS ce_press_release_url, 
ce.field_press_release_link_title AS ce_press_release_title, 
ce.field_press_release_link_attributes AS ce_press_release_attributes, 
(DATE_FORMAT(STR_TO_DATE(ce.field_start_date_value,'%Y-%m-%dT%T'),'%M %d, %Y %h:%i %p')) AS start, 
(DATE_FORMAT(STR_TO_DATE(ce.field_start_date_value2,'%Y-%m-%dT%T'),'%M %d, %Y %h:%i %p')) AS end, 
ce.field_web_resources_url AS ce_web_resources_url, 
ce.field_web_resources_title AS ce_web_resources_title, 
ce.field_web_resources_attributes AS ce_web_resources_attributes, 
node_revisions.body AS body, 
node_revisions.format AS node_revisions_format, 
node.title AS title 
FROM node node 
LEFT JOIN content_field_attach_gallery gallery ON node.vid = gallery.vid 
LEFT JOIN content_type_exhibitions_and_programs ce ON node.vid = ce.vid 
LEFT JOIN content_field_location location ON node.vid = location.vid 
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid 
WHERE (node.status <> 0) 
AND (node.type in ('exhibitions_and_programs')) 
AND '2010-01-19' BETWEEN (DATE_FORMAT(STR_TO_DATE(ce.field_start_date_value, '%Y-%m-%dT%T'), '%Y-%m-%d')) 
AND (DATE_FORMAT(STR_TO_DATE(ce.field_start_date_value2, '%Y-%m-%dT%T'), '%Y-%m-%d')) 
ORDER BY (DATE_FORMAT(STR_TO_DATE(ce.field_start_date_value, '%Y-%m-%dT%T'), '%Y-%m-%d')) DESC");

$num = FALSE;

while($r = db_fetch_array($q)) {
   $num = TRUE;
   $line = 'ok, found something!';
}

if($num == TRUE) {
  print $line;
} else {
  print 'No records found';
}
  • 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-13T11:34:54+00:00Added an answer on May 13, 2026 at 11:34 am

    It seems your db_query() and db_fetch_array() are custom functions. You should really var_dump($q) and replace your output code at the end entirely with var_dump(db_fetch_array($q)); to get some debug info on your problem.

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

Sidebar

Ask A Question

Stats

  • Questions 441k
  • Answers 441k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To enable right click on a particular element on the… May 15, 2026 at 5:45 pm
  • Editorial Team
    Editorial Team added an answer will_paginate accepts a Hash of options, including options to customize… May 15, 2026 at 5:45 pm
  • Editorial Team
    Editorial Team added an answer Try this: Comment.find_all_by_profile_id([user.friends, user].flatten) Same as: Comment.all(:conditions => {:profile_id =>… May 15, 2026 at 5:45 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.