Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-01-2012, 07:53 PM   PM User | #1
thepokemon
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
thepokemon is an unknown quantity at this point
[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.
thepokemon is offline   Reply With Quote
Old 12-01-2012, 08:59 PM   PM User | #2
KULP
Regular Coder

 
Join Date: Mar 2012
Posts: 166
Thanks: 5
Thanked 11 Times in 11 Posts
KULP is an unknown quantity at this point
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);
?>
KULP is offline   Reply With Quote
Users who have thanked KULP for this post:
thepokemon (12-01-2012)
Old 12-01-2012, 09:19 PM   PM User | #3
thepokemon
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
thepokemon is an unknown quantity at this point
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"
thepokemon is offline   Reply With Quote
Old 12-02-2012, 12:03 AM   PM User | #4
KULP
Regular Coder

 
Join Date: Mar 2012
Posts: 166
Thanks: 5
Thanked 11 Times in 11 Posts
KULP is an unknown quantity at this point
Quote:
Originally Posted by thepokemon View Post
"Fail3: Table 'microsof_league.tablename' doesn't exist"
You need to change "tablename" to your table name.
KULP is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:53 PM.


Advertisement
Log in to turn off these ads.