p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

php_databases thread: Problem Selecting from MySQL

Message #1 by "Philip Heins" <fireantz@d...> on Mon, 13 Jan 2003 15:27:02
> 	include("fcstring.php");
> 	mysql_connect($db_Host, $db_Username, $db_Pass) ||  
> die("<b><font 
> color=\"Red\" face=\"Arial\" size=\"2\">Error:</b></font><font 
> face=\"Arial\" size=\"2\"> Unable to connect to database: " . 
> mysql_error
> () . "</font>");

When you do a connect a resource id is returned. 
you should capture this like so..

	$db_handle = mysql_connect($db_Host, $db_Username, $db_Pass);

Then you select a database to work with like so..


Then when you issue your query you can do like so..

	$results = mysql_query($sqlquery,$db_handle);

Then to get results..

	while ( $row = @mysql_fetch_object($results) )

I also reccomend that you read the following article..




  Return to Index