[thelist] mySQL and PHP troubles

travis forden travis at treevis.com
Sun Sep 2 18:50:17 CDT 2001


Hi.

I'm learning mySQL and PHP. I'm working through some examples in the Beginning PHP4 by WROX. I have a mySQL table and I want to use PHP to display the userid and username.

the PHP script is:

<?php
include "common_db.inc.php";  [ specifies db_connect() function ]

$link_id = db_connect('sample_db');
$result = mysql_query("select * from user", $link_id);

while($query_data = mysql_fetch_row($result)) {
     echo "<p>'",$query_data[1],"' is also known as ",$query_data[3],"</p>";
}
?>

[$query_data[1] is the userid; $query_data[3] is the username]

When I run this script, I get the following error:
"Warning: Supplied argument is not a valid MySQL result resource in file.php on line 8"
[line 8 contains the while() function]

Any thoughts on why this is happening? It also happens when I rearrange the script to use mysql_fetch_array(), and mysql_fetch_object().

I'm running MySQL 3.23.32 and PHP 4.0.5.

Thanks,
travis





More information about the thelist mailing list