+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Need help with php mysql membership system

  1. #1
    chriscrowe43 is offline x10Hosting Member chriscrowe43 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    21

    Need help with php mysql membership system

    Hello, I have been looking over the php mysql membership system tutorial and I made an attempt to do it on my site, however I am a total noob to php and it didn't work for me. Honestly I didn’t know what to do with the existing code as far as plugging in my own db info I also created a db and table in my cpanel but I’m not really sure I even did that right. If someone could help me out that would be great!!! (lead me through the steps for my first time) or point me to a person i can talk with to do that. Or even point me to more explanatory help so that I can teach myself and actually get it done correctly. Thank you guys very much.

    ---------- Post added at 05:25 PM ---------- Previous post was at 03:40 PM ----------

    ok so here is the code for two php files that i am trying to use to test my database and check for a good connection. i put all the needed info into the files includeing the database name username and password but when i navigate to the php page www.pooperdoodles.ws/connect_to_mysql.php or www.pooperdoodles.ws/mysql_connect_quicktest.php i get a response that says "no database by that name" I have put the php files up in the www folder on my server. if that is the wrong place im not sure where i am suposed to put it. please help! thank you

    <?php
    $db_host = "localhost";
    $db_username = "put_db_username_here";
    $db_pass = "put_db_password_here";
    $db_name = "put_db_name_here";
    mysql_connect("$db_host","$db_username","$db_pass" ) or die(mysql_error());
    mysql_select_db("$db_name") or die("no database by that name");
    ?>

    <?php
    include_once "connect_to_mysql.php";

    echo "<br /><h2>You are successfully connected to your database.</h2><br /><br />
    Otherwise you would see an include warning, or a mysql connection error.<br /><br />
    Happy coding!
    ";
    ?>

  2. #2
    Dead-i's Avatar
    Dead-i is offline Community Advocate Dead-i has a spectacular aura about
    Join Date
    Aug 2011
    Location
    United Kingdom
    Posts
    1,448

    Re: Need help with php mysql membership system

    What database name and username are you using? I presume your scripts are hosted on x10Hosting.

  3. #3
    chriscrowe43 is offline x10Hosting Member chriscrowe43 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    21

    Re: Need help with php mysql membership system

    Quote Originally Posted by Dead-i View Post
    What database name and username are you using? I presume your scripts are hosted on x10Hosting.
    I thought that was a dangerous thing to include but what the heck

    here is the acctual code with all the "correct" info in it
    <?php
    $db_host = "localhost";
    $db_username = "ccrowe1_allie";
    $db_pass = "bedirect2002";
    $db_name = "ccrowe1_member";
    mysql_connect("$db_host","$db_username","$db_pass" ) or die(mysql_error());
    mysql_select_db("$db_name") or die("no database by that name");
    ?>

    <?php
    include_once "connect_to_mysql.php";
    echo "<br /><h2>You are successfully connected to your database.</h2><br /><br />
    Otherwise you would see an include warning, or a mysql connection error.<br /><br />
    Happy coding!
    ";
    ?>

    thank you for you reply it means alot to me

  4. #4
    Dead-i's Avatar
    Dead-i is offline Community Advocate Dead-i has a spectacular aura about
    Join Date
    Aug 2011
    Location
    United Kingdom
    Posts
    1,448

    Re: Need help with php mysql membership system

    Hmm, are you sure that the 'members' database exists? As in, is it listed in MySQL Databases in your cPanel?

    Btw, it's okay for you to post your username and database name, but not your password!

  5. #5
    chriscrowe43 is offline x10Hosting Member chriscrowe43 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    21

    Re: Need help with php mysql membership system

    Quote Originally Posted by Dead-i View Post
    Hmm, are you sure that the 'members' database exists? As in, is it listed in MySQL Databases in your cPanel?

    Btw, it's okay for you to post your username and database name, but not your password!
    yeah it looks like its there, along with the table i created and the user name. yes im useing x10 hosting btw. and i guess ill have to go change that password lol.

    ---------- Post added at 06:30 PM ---------- Previous post was at 06:24 PM ----------

    Quote Originally Posted by Dead-i View Post
    Hmm, are you sure that the 'members' database exists? As in, is it listed in MySQL Databases in your cPanel?

    Btw, it's okay for you to post your username and database name, but not your password!
    it is there although it says it is 0mb's and also I put these files in the www folder on the server could that be the wrong place becuase im not sure if it is or not?

  6. #6
    Dead-i's Avatar
    Dead-i is offline Community Advocate Dead-i has a spectacular aura about
    Join Date
    Aug 2011
    Location
    United Kingdom
    Posts
    1,448

    Re: Need help with php mysql membership system

    Hmm, that's weird. Okay, try creating a blank PHP file in public_html or www (doesn't really matter) with the following code, navigate to the file in your browser (or give me the link)

    PHP Code:
    <?php
    mysql_connect
    ('localhost''ccrowe1_allie''bedirect2002') or die ('Could Not Connect');
    mysql_select_db('ccrowe1_member') or die ('Database Does Not Exist');

    echo 
    "Database connection successful. No errors detected.";


    ---------- Post added at 08:33 PM ---------- Previous post was at 08:32 PM ----------

    PS. Yes, the www directory should be fine

  7. #7
    chriscrowe43 is offline x10Hosting Member chriscrowe43 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    21

    Re: Need help with php mysql membership system

    Quote Originally Posted by Dead-i View Post
    Hmm, that's weird. Okay, try creating a blank PHP file in public_html or www (doesn't really matter) with the following code, navigate to the file in your browser (or give me the link)

    PHP Code:
    <?php
    mysql_connect
    ('localhost''ccrowe1_allie''bedirect2002') or die ('Could Not Connect');
    mysql_select_db('ccrowe1_member') or die ('Database Does Not Exist');
     
    echo 
    "Database connection successful. No errors detected.";
    ---------- Post added at 08:33 PM ---------- Previous post was at 08:32 PM ----------

    PS. Yes, the www directory should be fine
    http://www.pooperdoodles.ws/testconnection.php

    ---------- Post added at 07:41 PM ---------- Previous post was at 07:38 PM ----------

    Quote Originally Posted by chriscrowe43 View Post
    I changed the password but i updated the code you sent me with the correct one!
    Reply Database does not exist

  8. #8
    Dead-i's Avatar
    Dead-i is offline Community Advocate Dead-i has a spectacular aura about
    Join Date
    Aug 2011
    Location
    United Kingdom
    Posts
    1,448

    Re: Need help with php mysql membership system

    Try this: Login to your cPanel and go to 'phpMyAdmin'. On the left hand side, there should be a listing of databases (some are created automatically). Is 'members' there?

  9. #9
    chriscrowe43 is offline x10Hosting Member chriscrowe43 is an unknown quantity at this point
    Join Date
    Aug 2011
    Posts
    21

    Re: Need help with php mysql membership system

    Quote Originally Posted by Dead-i View Post
    Try this: Login to your cPanel and go to 'phpMyAdmin'. On the left hand side, there should be a listing of databases (some are created automatically). Is 'members' there?

    when i first go into php my admin on the left side all i see is the table called user that i created
    but if i click on the databases button under database in the main content area of the page i see the ccrowe1_member listed under database but still not on the left side bar

  10. #10
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Need help with php mysql membership system

    Quote Originally Posted by chriscrowe43 View Post
    I thought that was a dangerous thing to include but what the heck.
    The password is what's dangerous to include. If you posted your actual password, change it right now. Not only have others seen it, but search engines may have cached the page.

    Please use [php], [html] or [code] tags (as appropriate) to separate and format code.

    There's no advantage to placing double quotes around a variable. All it does is make PHP take extra time (admittedly, very, very little time) to evaluate the string and interpolate the variable. The value of "$db_host" is equal to $db_host.

    <br/> isn't semantic. Use paragraphs or whatever is most appropriate.

    You shouldn't be using the old mysql extension, even to test DB connection settings. You won't be using it in production code, so a successful test isn't worth anything.

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
      <head>
        <title>DB Connection test</title>
      </head>
      <body>
        <?php
        
    // make sure only admins see this page by e.g. using HTTP authentication

        
    $db_host "localhost";
        
    $db_name "ccrowe1_member";
        
    $db_username "ccrowe1_allie";
        
    $db_pass "****";
        try {
            
    $db = new PDO("mysql:host=localhost;db=$db_name"$db_username$db_pass);
            include_once 
    "connect_to_mysql.php";
            
    ?>
            <h2>DB Connection Succeeded</h2>
            <p>You are successfully connected to your database. Otherwise you would see an include warning, or a mysql connection error.</p>
            <p>Happy coding!</p>
            <?php 
        
    } catch (PDOException $exc) {
            
    ?>
            <h2>DB Connection Failed</h2>
            <pre><?php
            
    echo $exc;
            
    ?></pre><?php
        
    }
        
    ?>
      </body>
    </html>
    Since database connection creation (including managing the database credentials) should be the responsibility of one module, write that module and test it to see if your DB connection will work, rather than writing a script to test DB connection settings (which leads to a duplication of effort and doesn't reveal very much). This is unit testing. See "[PHP] MySQL and PHP" and "Display all that would be secret while Mysql is broken" for some partial examples of a class to manage local DB connections.

    Quote Originally Posted by chriscrowe43 View Post
    when i first go into php my admin on the left side all i see is the table called user that i created
    Table, or database? The left view should show databases, not tables. Please post a screenshot.
    Last edited by misson; 08-28-2011 at 03:09 PM.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Tutorial: PHP/MySQL Membership System
    By Jesse in forum Tutorials
    Replies: 31
    Last Post: 03-20-2012, 03:48 PM
  2. MySQL chatscript - Membership upgradation
    By rmkecealumni98 in forum Free Hosting
    Replies: 6
    Last Post: 01-22-2011, 07:17 AM
  3. Creating a Fully Developed Login Membership system...
    By vrufusx65v in forum Programming Help
    Replies: 6
    Last Post: 12-17-2010, 10:30 PM
  4. ASP.NET Membership/Authentication with MySql
    By haysoft in forum Free Hosting
    Replies: 4
    Last Post: 12-16-2009, 04:40 PM
  5. MySql Membership Provider for ASP.NET Configuration
    By haysoft in forum Programming Help
    Replies: 4
    Last Post: 12-11-2009, 06:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers