SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question No database selected

    Having an issue. Not selecting databse.

    No errors are generated.

    Here is the code...thoughts???

    PHP Code:
    <?php
      error_reporting
    (E_ALL);
    ini_set("display_errors"1);
      
      
    // Start the session
      
    require_once('startsession.php');
      
       
    // Connect to the database 
      
    require_once('connectvars.php');

    $dbc mysql_connect(DB_HOSTDB_USERDB_PASSWORD);
    mysql_select_db(DB_NAME);


      
    // Retrieve the user data from mysql
      
    $query "SELECT user_id, first_name, picture FROM mismatch_user WHERE first_name IS NOT NULL ORDER BY join_date DESC LIMIT 5";
      
    $data mysql_query($query$dbc);
    ?>

    <html>

    <head>

    <link rel="stylesheet" type="text/css" href="style.css" />

    </head>

    <body>

    <div class="main-content">

    <div class="userhomecontainer">

    <div>
    <?php
      
    // Insert the page header
      
    $page_title 'Where opposites attract!';
      require_once(
    'header.php');

      require_once(
    'appvars.php');
    ?>

    </div>

    <div style="clear: both"></div>
      
      <?php

      
    // Show the navigation menu
      
    require_once('navmenu.php');  
      
    ?>
      
    <!--  <?php

      
    // Loop through the array of user data, formatting it as HTML
      
    echo '<h4>Systek Employee Portal</h4>';
      echo 
    '<table style="padding: 10px;">';
      while (
    $row mysql_fetch_array($data)) {
        if (
    is_file(MM_UPLOADPATH $row['picture']) && filesize(MM_UPLOADPATH $row['picture']) > 0) {
          echo 
    '<tr><td><img src="' MM_UPLOADPATH $row['picture'] . '" alt="' $row['first_name'] . '" /></td>';
        }
        else {
          echo 
    '<tr><td><img src="' MM_UPLOADPATH 'nopic.jpg' '" alt="' $row['first_name'] . '" /></td>';
        }
        if (isset(
    $_SESSION['user_id'])) {
          echo 
    '<td><a href="viewprofile.php?user_id=' $row['user_id'] . '">' $row['first_name'] . '</a></td></tr>';
        }
        else {
          echo 
    '<td>' $row['first_name'] . '</td></tr>';
        }
      }
      echo 
    '</table>';

      
    mysql_close($dbc);
    ?>-->


    <?php
      
    require_once('login.php');
    ?>

    <?php
      
    // Insert the page footer
      
    require_once('footer.php');
    ?>

    </div></div>

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use mysql_error to see the text of the error message
    my mobile portal
    ghiris.ro

  3. #3
    SitePoint Zealot Kayarc's Avatar
    Join Date
    Sep 2009
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $dbc 
    mysql_connect(DB_HOSTDB_USERDB_PASSWORD); 
    mysql_select_db(DB_NAME,$dbc);
    ?>
    DB_NAME is set incorrectly I assume

    edit:
    try:
    PHP Code:
    <?php mysql_select_db(DB_NAME,$dbc) or die('Could not select database.');?>
    and

    http://www.php.net/mysql_error
    Phoenix Arizona Web Design | info *at* kayarc.com | 602.633.2676

  4. #4
    Trash Boat mkoenig's Avatar
    Join Date
    Aug 2007
    Posts
    1,232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    What i always do is get as basic as possible and build my way back up. Just start with a new page called somepage.php

    PHP Code:
    <?
    //connect
    $db mysql_pconnect("localhost""user""pass");
    mysql_select_db("database");

    //simple query one result
    $query "Select * from table limit 1";
    $result mysql_query($query);
    while(
    $row mysql_fetch_assoc($result)){
    echo 
    $row['fieldname'];
    }
    ?>
    If that works ok then build up from there, if you get to the point where it doesn't call the table name try and echo out that table name variable
    PHP Code:
    <?
    echo $table;
    ?>
    if you get no response then the variable is not getting through and you need to dissect it further.

    Im not the best at php but i always break stuff down and seem to make it through with some sitepoint help.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mkoenig View Post
    What i always do is get as basic as possible and build my way back up. Just start with a new page called somepage.php

    PHP Code:
    <?
    //connect
    $db mysql_pconnect("localhost""user""pass");
    mysql_select_db("database");

    //simple query one result
    $query "Select * from table limit 1";
    $result mysql_query($query);
    while(
    $row mysql_fetch_assoc($result)){
    echo 
    $row['fieldname'];
    }
    ?>
    If that works ok then build up from there, if you get to the point where it doesn't call the table name try and echo out that table name variable
    PHP Code:
    <?
    echo $table;
    ?>
    if you get no response then the variable is not getting through and you need to dissect it further.

    Im not the best at php but i always break stuff down and seem to make it through with some sitepoint help.
    Didnt work.

  6. #6
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,994
    Mentioned
    100 Post(s)
    Tagged
    0 Thread(s)
    Copy and paste here the line where in connectvars.php where the value for the constant DB_NAME is defined.
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  7. #7
    SitePoint Zealot
    Join Date
    Mar 2008
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Copy and paste here the line where in connectvars.php where the value for the constant DB_NAME is defined.
    define('DB_NAME', 'mismatch');

  8. #8
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,994
    Mentioned
    100 Post(s)
    Tagged
    0 Thread(s)
    Have you checked that a database exists called "mismatch" on the server?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  9. #9
    SitePoint Zealot Kayarc's Avatar
    Join Date
    Sep 2009
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Have you checked that a database exists called "mismatch" on the server?
    I'm curious now whether this was the embarrassing issue
    Phoenix Arizona Web Design | info *at* kayarc.com | 602.633.2676

  10. #10
    Trash Boat mkoenig's Avatar
    Join Date
    Aug 2007
    Posts
    1,232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kayarc View Post
    I'm curious now whether this was the embarrassing issue
    Hahah maybe, if so we've all done it before im sure

  11. #11
    SitePoint Zealot Kayarc's Avatar
    Join Date
    Sep 2009
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mkoenig View Post
    Hahah maybe, if so we've all done it before im sure
    No doubt about it!
    Phoenix Arizona Web Design | info *at* kayarc.com | 602.633.2676


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •