Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    [Help] Page not displaying at all, when php code connects to MySQL Database

    I have no idea what's wrong. I need personal help, I have next to 0 experience with PHP or MySQL. If someone could help me over skype or Teamviewer I'd be very grateful.

  • #2
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Can't help much without further details but here are the basic steps to working with a database. Perhaps spend some time learning the basics first.
    PHP Code:
    <?php
    //********************************************************
    //This connects our page to MySQL. Change to password and*
    //if there is no password, take it out.                  *
    //********************************************************
    $connection mysql_connect("localhost""root""password" );
    if(!
    $connection)
    {
        die(
    "Fail: " mysql_error());
    }

    //********************************************************
    //This selects the database that we will be working with.*
    //Change dbname to your database name.                   *
    //********************************************************
    $dbselect mysql_select_db("dbname"$connection);    
    if(!
    $dbselect)
    {
        die(
    "Fail2: " mysql_error());
    }
    ?>
    <html>
        <head>
            
        </head>
        <body>
            <?php
                
    //********************************************************
                //This pulls everything from tablename (change name)     *
                //********************************************************
                
    $result mysql_query("SELECT * FROM tablename"$connection );
            
                if(!
    $result)
                {
                    die(
    "Fail3: " mysql_error());
                }

                while(
    $row mysql_fetch_array($result))
                {
                    echo 
    $row['columnname'] . "</br>";
                }
                
            
    ?>
            
        </body>
    </html>

    <?php
        mysql_close
    ($connection);
    ?>

  • Users who have thanked KULP for this post:

    thepokemon (12-01-2012)

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by KULP View Post
    Can't help much without further details but here are the basic steps to working with a database. Perhaps spend some time learning the basics first.
    PHP Code:
    <?php
    //********************************************************
    //This connects our page to MySQL. Change to password and*
    //if there is no password, take it out.                  *
    //********************************************************
    $connection mysql_connect("localhost""root""password" );
    if(!
    $connection)
    {
        die(
    "Fail: " mysql_error());
    }

    //********************************************************
    //This selects the database that we will be working with.*
    //Change dbname to your database name.                   *
    //********************************************************
    $dbselect mysql_select_db("dbname"$connection);    
    if(!
    $dbselect)
    {
        die(
    "Fail2: " mysql_error());
    }
    ?>
    <html>
        <head>
            
        </head>
        <body>
            <?php
                
    //********************************************************
                //This pulls everything from tablename (change name)     *
                //********************************************************
                
    $result mysql_query("SELECT * FROM tablename"$connection );
            
                if(!
    $result)
                {
                    die(
    "Fail3: " mysql_error());
                }

                while(
    $row mysql_fetch_array($result))
                {
                    echo 
    $row['columnname'] . "</br>";
                }
                
            
    ?>
            
        </body>
    </html>

    <?php
        mysql_close
    ($connection);
    ?>
    "Fail3: Table 'microsof_league.tablename' doesn't exist"

  • #4
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Quote Originally Posted by thepokemon View Post
    "Fail3: Table 'microsof_league.tablename' doesn't exist"
    You need to change "tablename" to your table name.


  •  

    Posting Permissions

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