Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
richieio
Forum Newbie
Posts: 2 Joined: Wed Jul 17, 2002 7:45 am
Location: New Jersey
Post
by richieio » Wed Jul 17, 2002 7:45 am
ok I am new with php and mysql so dont hang me
I'm trying to fetch some rows here using:
while ($row = $result->mysql_fetch_row()){
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td></tr>\n";
}
and i get this!
Fatal error: Call to undefined function: mysql_fetch_row() in /usr/local/apache/htdocs/admin_add.php on line 74
thats line 74 up there.
whats goin on here? please help, i just installed apache w/php & mysql and i'm trying to learn.
Thx,
llimllib
Moderator
Posts: 466 Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD
Post
by llimllib » Wed Jul 17, 2002 8:01 am
Code: Select all
while($row = mysql_fetch_row($result)) {
echo "...";
}You were getting an error because the '->' notation selects a method that belongs to an object. In other words, you were trying to call the 'mysql_fetch_row' method of object $result - except $result is not an object. Do a print_r($result) and you'll see that it's only an integer. So, PHP tried to find the mysql_fetch_row method *inside* $result, which failed. Instead, you want to call the mysql_fetch_row method and supply the argument, as listed above.
richieio
Forum Newbie
Posts: 2 Joined: Wed Jul 17, 2002 7:45 am
Location: New Jersey
Post
by richieio » Wed Jul 17, 2002 8:45 am
awesome, thanks for the quick reply.
Ok i just tried it and i got this warning:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /usr/local/apache/htdocs/admin_add.php on line 74
Is there somewhere i can go that will tell me what this stuff means so i dont have to come ask you guys everytime something wrong happens
Thx!
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Jul 17, 2002 8:51 am
That error probably means that there is a problem with your query try doing the following:
Code: Select all
$sql = "SELECT whatever FROM yourtable WHERE somestuff";
$result = mysql_query($sql) or die(mysql_error().'<br />'.$sql);
Mac