The following means you have not opened a link to your database.
Concerntrate your efforts there.

Warning: Supplied argument is not a valid MySQL-Link 
resource in /var/www/html/list.php3 on line 26

-----Original Message-----
From: Ken Thompson [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 3:23 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Resource link errors


Hello all,
I'm very new to php and have been beating my head on the wall over this for
2 
days. I've searched through the php documentation but I guess I either don't

know where or what to look for or don't understand what I'm seeing.
I think this has to be an array but the original doesn't seem to think
so.(see below) 
I've tried ($myrow = mysql_fetch_array($result)) and still get the same 
errors.
The original that I used as an example works OK showing the results of Name,

Position. They didn't include a data cell for $myrow[3] ...........
=========================================================
THIS WORKS:
<?php

$title = "Welcome to the Web-Site of"; /*I commented this out and finaly 
removed it cuz I don't want the title echoed in the final page.*/

include("header.inc");

$result = mysql_query("SELECT * FROM employees",$db);

echo "<table border=1>\n";

echo "<tr><td>Name</td><td>Position</tr>\n";

while ($myrow = mysql_fetch_row($result)) {

        echo("<tr><td>%s %s</td><td>%s</tr>\n", $myrow[1], $myrow[2], 
$myrow[3]);

}

echo "</table>\n";
include("footer.inc");

?>
===========================================================
What I am trying to do is to return the results of the query into a table 
with these items:
+-----------+-------------+------+-----+---------+----------------+
| Field     | Type        | Null | Key | Default | Extra          |
+-----------+-------------+------+-----+---------+----------------+
| id        | tinyint(4)  |      | PRI | NULL    | auto_increment |
| year      | int(4)      | YES  |     | NULL    |                |
| make      | varchar(20) | YES  |     | NULL    |                |
| model     | varchar(20) | YES  |     | NULL    |                |
| engine    | varchar(20) | YES  |     | NULL    |                |
| fuel      | varchar(8)  | YES  |     | NULL    |                |
| trans     | varchar(10) | YES  |     | NULL    |                |
| condition | varchar(20) | YES  |     | NULL    |                |
| price     | varchar(10) | YES  |     | 0       |                |
| location  | varchar(20) | YES  |     | NULL    |                |
+-----------+-------------+------+-----+---------+----------------+
These are the errors that show up when I run the page in the browser.
The database is local and I'm on Linux-Mandrake 8.1 using Apache web server.
I can get the results I want from the command line, that is I can make 
queries and get the proper info returned. 
what have I done to cause it not to work?


Warning: Supplied argument is not a valid MySQL-Link 
resource in /var/www/html/list.php3 on line 26
 
Warning: Supplied argument is not a valid MySQL result 
resource in /var/www/html/list.php3 on line 32

 THIS DOESN'T:
I get the table and the item name e.g. Year, Make etc. 
Once I get the 3 cells returning the proper info, I want to add the rest of 
the cells needed to display all the info in the web page. I don't think it 
should be a problem, comments on this?

<?php

include("header.inc");

//(Line 26 below, everything above "<?php" is plain html.) 
$result = mysql_query("SELECT * FROM autos",$db);

echo "<table border=1>\n";

echo "<tr><td>Year</td><td>Make</td><td>Model</td></tr>\n";

//(Line 32 below) 
while ($myrow = mysql_fetch_row($result)) {

//What does the '%s' mean? I read it someplace in the tutorial
//but can't find it now.

        printf("<tr><td>%s %s</td><td>%s</tr>\n", $myrow[1], $myrow[2], 
$myrow[3]);

}

echo "</table>\n";
include("footer.inc");

?>
-- 

Ken Thompson, North West Antique Autos
Payette, Idaho
Email: [EMAIL PROTECTED]
http://www.nwaa.com
Sales and brokering of antique autos and parts.

Linux- Coming Soon To A Desktop Near You
Registered Linux User #183936

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to