Some Sqlite/php help :(
Posted: 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 : (
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 : (
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;
}
$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 : (