Jump to content

Warning: mysql_select_db() expects parameter 2 to be resource, null given


Modernvox

Recommended Posts

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++;     
  }


?> 

                                       

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.