Modernvox Posted February 21, 2010 Share Posted February 21, 2010 Hi, I'm getting this warning message in the following code and I am wondering if it's because I haven't any input in the database fields yet? <?php $dbx= mysql_connect("host", "user", "pass"); //include before any database implematation if (!$dbx) { die('Could not connect: ' . mysql_error()); } $st = isset($_POST['submit']) ? $_POST['state'] : ''; $category= isset($_POST['category']); $i = 1; //set start point; $limit = 70; //set limit; if ($category= "class") { $dbname= "mydb"; mysql_select_db($dbname, $conn); $result = mysql_query("SELECT * FROM musicians WHERE location = '$st'"); While($musicians = mysql_fetch_array($result)) { echo "<a href=\"{$musicians[title]}\" target=\"_blank\">{$musicians[actual_location]}<font size=\"3\"></font></a><br />"; print "<BR />\n"; echo " $venue[title] " . " $musicians[actual_location] <br/><br/> $musicians[name] <br/> $musicans[genre] <br/> $musicians[ratings]"; echo " a href=\"http://dezi9er.net16.net/flagsystem.php\" target=\_blank\">Flag this listing</a>"; echo "<form action=\"flagsystem.php\" name= \"flagsystem\" method= \"post\">"; echo "<select name= \"flagReason\">"; echo "<option value= \"dontExist\">Venue doesn't exist\"</option>"; echo "<option value= \"notHiring\">Venue no longer hiring musicians\"</option>"; echo "<option value= \"misplaced\">Misplaced listing\"</option>"; echo "<option value= \"prohibited\"Prohibited listing\"</option>"; echo "</select>"; echo "input type= \"submit\" value= \"Flag this for removal\" name=\"submit\" /></form>"; } } $st= "bham"; $urls= array("http://" . $st . ".craigslist.org"); foreach ($urls as $url) { $html = file_get_contents("$url/muc/"); preg_match_all('/<a href="([^"]+)">([^<]+)<\/a>[^<]*<font size="-1">([^"]+)<\/font>/s', $html,$posts,PREG_SET_ORDER); //echo "<pre>";print_r($posts); foreach ($posts as $post) { //print_r $post[3]; //HTML $post[2] = str_ireplace($url,"",$post[2]); //remove domain echo "<a href=\"{$post[1]}\" target=\"_blank\">{$post[2]}<font size=\"3\">{$post[3]}</font></a><br />"; print "<BR />\n"; } if ($i == $limit) { break; } $i++; } ?> Quote Link to comment Share on other sites More sharing options...
trq Posted February 21, 2010 Share Posted February 21, 2010 You database connection is stored within $dbx, your passing an undefined variable $conn to mysql_select_db. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.