PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Straterra
Forum Regular
Posts: 527 Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:
Post
by Straterra » Thu Dec 25, 2003 11:25 am
I have this code..yet, it returns the error Invalid Argument Supplied For Foreach. This is the code....
Code: Select all
<?php
$dbname = 'eckbios';
if ($db = sqlite_open($dbname, 0666, $sqliteerror)){
$users = (sqlite_query($db, "SELECT socomname from clanprofile ORDER BY socomname"));
foreach ( $users as $val ) {
?>
<a href="
<?php
echo "pro.php?user=$val";
?>
">
<?php
echo "$val";
?>
</a>
<?php
echo "<br><br>";
}
}
?>
aquila125
Forum Commoner
Posts: 96 Joined: Tue Dec 09, 2003 10:39 am
Location: Belgium
Post
by aquila125 » Thu Dec 25, 2003 1:49 pm
sqlite_query returns a resource, not an array...
this is how it should be:
Code: Select all
<?php
$dbname = 'eckbios';
if ($db = sqlite_open($dbname, 0666, $sqliteerror)){
$result = (sqlite_query($db, "SELECT socomname from clanprofile ORDER BY socomname"));
while ($row=sqlite_fetch_array($result) {
?>
<a href="
<?php
echo "pro.php?user=".$row['socomname'];
?>
">
<?php
echo $row['socomname'];
?>
</a>
<?php
echo "<br><br>";
}
}
?>