Hi,
I took an onlune tutorial that looked about 3 years old. My Sql table looks like this:
CREATE TABLE employees ( id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, first varchar(20), last varchar(20), address varchar(255), position varchar(50), PRIMARY KEY (id), UNIQUE id (id));INSERT INTO employees VALUES (1,'Bob','Smith','128 Here St, Cityname','Marketing Manager');
INSERT INTO employees VALUES (2,'John','Roberts','45 There St , Townville','Telephonist');
INSERT INTO employees VALUES (3,'Brad','Johnson','1/34 Nowhere Blvd, Snowston','Doorman');
=========================
My actual cript resembles this:
<?php
$dbh=mysql_connect ("localhost", "user_content", "content") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("user_content");
$result = mysql_query("SELECT * FROM employees",$db);
printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
printf("Last Name: %s<br>\n", mysql_result($result,0,"last"));
printf("Address: %s<br>\n", mysql_result($result,0,"address"));
printf("Position: %s<br>\n", mysql_result($result,0,"position"));
?>
===================
All I am trying to do is print these fields out on a generic web page to see if it works but I am presented with these errors:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/user/public_html/php/index.php on line 12
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/user/public_html/php/index.php on line 16
First Name:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/user/public_html/php/index.php on line 20
Last Name:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/user/public_html/php/index.php on line 24
Address:
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/user/public_html/php/index.php on line 28
Position:
Are my print calls outdated or does my code need some work?
Thanks,
Matt