Page 1 of 1

Some Sqlite/php help :(

PostPosted: Tue Jul 20, 2010 7:12 am
by CTS_AE
Here's something really basic and generic that I have
I tried someone's tutorial, and it worked great with their info
Tutorial: http://henryranch.net/software/ease-int ... p-and-pdo/

Then when I try with my code would always return nothing so I decided to see if it would pass the "is_array"
which it's not passing
so I'm just wondering if someone could shed some light on this
Maybe there's something I'm not understanding about sqlite
or php in general : (

    try {
  $db = new PDO("sqlite:gg_database.db");
   
    print "<table border=1>";
    print "<tr><td>Name</td><td>UniqueID</td><td>Wins</td><td>TimeStamp</td></tr>";
    $result = $db->query('SELECT * FROM gg_wins');

    if(is_array($result))
    {   

       foreach($result as $row)
        {
          print "<tr><td>".$row['name']."</td>";
          print "<td>".$row['uniqueid']."</td>";
          print "<td>".$row['wins']."</td>";
          print "<td>".$row['timestamp']."</td></tr>";
        }
        print "</table>";

    }
    else
    {
    print "FAILE";
    print "   Hmm ".$result;
    }


this is what it's returning error wise
Warning: Invalid argument supplied for foreach()


Edit: funny part is, I tried the "is_array" with their code and it doesn't report to be true, which is odd, but I figure that's the issue with foreach not working, but I'm still confused : (

PostPosted: Thu Jul 22, 2010 10:21 am
by CTS_AE
I got this working, thank god...
phew so excited :D
Not exactly sure what was going on, but I think eventually some time I was saving blank db's or something, now it grabs the right file and writes to the right name ; ) lol.
I was about to freak out, or maybe I have been the past week trying to do this.

If I get something nice I'll make sure to post it up for the community, or at least post the source here for anyone else who wants to expand on it : )

PostPosted: Thu Jul 22, 2010 11:50 am
by XE_ManUp
Awesomw job, man!