Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Why is nothing returned from SQLite DB? (PHP)

  1. #11
    Join Date
    May 2011
    Beans
    253
    Distro
    Ubuntu 15.10 Wily Werewolf

    Re: Why is nothing returned from SQLite DB? (PHP)

    WOW... I'm even more confused now! This script continues to display NOTHING. I did, however, enclose lines 43-51 inside a while loop and had along w/ a counter. The counter only goes up to the # of results! So it is pulling the results, I'm just unable to print them out.

    But what is just COMPLETELY giving me a headache is that I decided to skip this script for now and go on to another one. Here is the code for that one:
    Code:
          1 <?
          2 $pg_title = "Home";
          3 
          4 include_once "header.php";
          5 
          6 $query = "SELECT date, name, country, phone, phonetype FROM lead_info";
          7 $result = sqlite_query($query, $db) or die("Select Query Failed");
          8 ?>
          9 
         10 <table width="1000" align="center" border="1">
         11 
         12 <?
         13 while($row = sqlite_fetch_array($result))
         14 {
         15         print("<tr>");
         16         print("  <td>" . $row["date"]                   . "</td>");
         17         print("  <td>" . $row["name"]                   . "</td>");
         18         print("  <td>" . $row["country"]                . "</td>");
         19         print("  <td>" . $row["phone"]                  . "</td>");
         20         print("  <td>" . $row["phonetype"]              . "</td>");
         21         print("</tr>");
         22 }
         23 ?>
         24 
         25 </table>
         26 
         27 <?
         28 include_once "footer.php";
         29 ?>
    THIS PAGE WORKS! IT DISPLAYS EVERYTHING! Does anyone see any difference in the query or the way that the retrieved vars are handled and printed?

    EDIT: PS: Before posting this last reply, I went back to the original script and changed $row['foo'] to $row["foo"], but the problem continued.
    Last edited by kevinharper; November 6th, 2011 at 01:23 AM.
    Kevin Harper
    http://www.kevinharper.com/


    Ubuntu: Because rebooting is ONLY for installing hardware

  2. #12
    Join Date
    May 2006
    Beans
    1,790

    Re: Why is nothing returned from SQLite DB? (PHP)

    Quote Originally Posted by kevinharper View Post
    WOW... I'm even more confused now! This script continues to display NOTHING. I did, however, enclose lines 43-51 inside a while loop and had along w/ a counter. The counter only goes up to the # of results! So it is pulling the results, I'm just unable to print them out.

    But what is just COMPLETELY giving me a headache is that I decided to skip this script for now and go on to another one. Here is the code for that one:
    Code:
          1 <?
          2 $pg_title = "Home";
          3 
          4 include_once "header.php";
          5 
          6 $query = "SELECT date, name, country, phone, phonetype FROM lead_info";
          7 $result = sqlite_query($query, $db) or die("Select Query Failed");
          8 ?>
          9 
         10 <table width="1000" align="center" border="1">
         11 
         12 <?
         13 while($row = sqlite_fetch_array($result))
         14 {
         15         print("<tr>");
         16         print("  <td>" . $row["date"]                   . "</td>");
         17         print("  <td>" . $row["name"]                   . "</td>");
         18         print("  <td>" . $row["country"]                . "</td>");
         19         print("  <td>" . $row["phone"]                  . "</td>");
         20         print("  <td>" . $row["phonetype"]              . "</td>");
         21         print("</tr>");
         22 }
         23 ?>
         24 
         25 </table>
         26 
         27 <?
         28 include_once "footer.php";
         29 ?>
    THIS PAGE WORKS! IT DISPLAYS EVERYTHING! Does anyone see any difference in the query or the way that the retrieved vars are handled and printed?

    EDIT: PS: Before posting this last reply, I went back to the original script and changed $row['foo'] to $row["foo"], but the problem continued.
    The only thing that seems relevant is that the working code has the columns named explicitly in the query, while you have *. But there ought to be a way to get at the individual columns. Just an idea: maybe they can be accessed this way: $row['lead_info.date']. There is a function print_r or something which displays a whole array, so do print_r($row), too.

  3. #13
    Join Date
    May 2011
    Beans
    253
    Distro
    Ubuntu 15.10 Wily Werewolf

    Re: Why is nothing returned from SQLite DB? (PHP)

    Kudos, Arndt!

    The issue does in fact ONLY come up when I "SELECT *...".

    I ended up having to redo the table and a lot of the scripts that wrote to it and retrieved from it.

    After looking at your response, I tested it out and eliminated "*" from my SELECT's. :S Looks like I'm going to stick to this. I almost certain that I am having these issues because I am using a PHP4x version and the system isn't really equipped to handle anything newer. I also had to break up my emails to username and domain entries because I was unable to use php functions to convert to literal string. Those required some plugins and, well... not worth it for what I'm doing.

    Seriously though... thank you for the response. It would have taken me a long time to see that.
    Kevin Harper
    http://www.kevinharper.com/


    Ubuntu: Because rebooting is ONLY for installing hardware

Page 2 of 2 FirstFirst 12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •