[thelist] PHP & MySQL - Generating dynamic pages...

Jay Blanchard jay.blanchard at niicommunications.com
Fri Jul 26 13:32:10 CDT 2002


[snip]
 Am I missing anything?
[/snip]

What version of PHP? Is register_globals turned off in your php.ini?

Try this
<?php
//check connection to db
if(!($dbconnect = mysql_pconnect("127.0.0.1", "username", "password"))){
	print("Failed to connect to database!\n");
	exit();
	}
if(!mysql_select_db("db", $dbconnect)){
	print("Failed to select database!\n");
	exit();
	}

$state = $_GET['State'];
print($state); //to make sure you're getting what you wanted

$query = SELECT * ";
$query .= "FROM db ";
$query .= "WHERE State = '" . $state . "'
//the above method of coding the query is for neatness only

print($query); //so that you can see the query

//do the query and return errors if not right
if(!($dbquery = mysql_query($query, $dbconnect))){
   print("MySQL reports this error: " . mysql_error());
   exit;
}
?>

HTH!

Jay




More information about the thelist mailing list