[thelist] PHP and MySQL Multiple Query/Array

John Corry webshot at members.evolt.org
Mon Jan 20 19:36:01 CST 2003


The WHERE clause value has to be in single quotes:

I usually try to keep my query separate from where I run it.

You might also want to look into a good MySQL class for your db
interaction...makes it *so* much easier.

$q = "SELECT pic FROM users WHERE author = '".$author[author]."'";
$result = mysql_query( $q );

Aloha,
John

PS - I have a *really good* PHP tip I'm saving for when I really need
one...go ahead, provoke me ;)

> -----Original Message-----
> From: thelist-admin at lists.evolt.org
> [mailto:thelist-admin at lists.evolt.org] On Behalf Of Razzak Jallow
> Sent: Monday, January 20, 2003 3:19 PM
> To: thelist at lists.evolt.org
> Subject: [thelist] PHP and MySQL Multiple Query/Array
>
>
> 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>';
>
> --
> * * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !





More information about the thelist mailing list