[thelist] PHP and MySQL Multiple Query/Array

Razzak Jallow razzak at mac.com
Mon Jan 20 19:19:01 CST 2003


Hey all.  I've been fuming over this for a long time now and am hoping
someone can shed some light on it, because I'm amazingly stuck.  I'm
trying to get information from two tables on the same database, but
keep getting an error in the two lines after //select pic.  Any help is
greatly appreciated.  I've tried messing with $author[author] and
changing it to an absolute value such as `Bill` but no luck.


		$db = "gridiron";
     	$user = "----";
     	$pass = "----";

		$link = mysql_connect( "localhost", $user, $pass );
		if ( ! $link )
			die( "Couldn't connect to MySQL" );
		mysql_select_db( $db, $link )
			or die ( "Couldn't open $db: ".mysql_error() );
		$result = mysql_query( "SELECT author FROM articles where submitdt =
$id" );
		$author = mysql_fetch_array( $result, MYSQL_ASSOC );

		//select pic
		$result = mysql_query( "SELECT pic FROM users where author =
$author[author]");		$pic = mysql_fetch_array( $result, MYSQL_ASSOC );

		//html it
		print '<div align="center"><img
src="../images/profilepics/'.$pic["pic"].'" alt="'.$author["author"].'"
width="88" height="76" border="0"></div>';




More information about the thelist mailing list