Some Sqlite/php help :(

Having problems with GunGame5 (NOT FOR BUGS)? Ask here!

Some Sqlite/php help :(

Postby CTS_AE » Tue Jul 20, 2010 7:12 am

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 : (
CTS_AE

Private
Private
 
Posts: 20
Joined: Wed Jul 14, 2010 12:55 pm

Postby CTS_AE » Thu Jul 22, 2010 10:21 am

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 : )
CTS_AE

Private
Private
 
Posts: 20
Joined: Wed Jul 14, 2010 12:55 pm

Postby XE_ManUp » Thu Jul 22, 2010 11:50 am

Awesomw job, man!
XE_ManUp

Site Admin
Site Admin
 
Posts: 662
Joined: Sat Sep 06, 2008 3:36 am



Return to Troubleshooting (NOT FOR BUGS)

Who is online

Users browsing this forum: No registered users and 9 guests