Results 1 to 3 of 3

Thread: [RESOLVED] include & mysql_connect() error.

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Resolved [RESOLVED] include & mysql_connect() error.

    My website is currently hosted by a free server: **********.com

    Error Messages:

    PHP Error Message

    Warning: include() [function.include]: Failed opening '/Includes/database_info.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a1401476/public_html/adduser.php on line 11

    Free Web Hosting

    PHP Error Message

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/a1401476/public_html/adduser.php on line 12

    Free Web Hosting
    Could not connect: Access denied for user 'nobody'@'localhost' (using password: NO)
    There is a registration form, when you click the Register (Submit) button it executes adduser.php. (Form action="adduser.php")

    The problem is that i need the adduser.php script to send the registration info to a database to log the new user. It is having problems connecting to the database, from the error it gave (above) i am guessing it is because something is wrong with my include. Below i have supplied the file that is being included, with modified values for the variables (security purposes), and the bit of mySQL code on the page adduser.php.

    File: /public_html/Includes/database_info.php
    Code:
    <?php
    $sql_servername = "mysql7.**********.com";
    $sql_username = "myusername";
    $sql_password = "mypassword";
    ?>
    .


    File: /public_html/adduser.php
    (note * this is just the mySQL part of my code
    i replaced the other code ontop and below with comments)
    Code:
    <?php
    //Code here...
    //Code here...
    //Code here...
    //Code here...
    include ("/Includes/database_info.php");
    $con = mysql_connect($sql_servername,$sql_username,$sql_password);
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    mysql_select_db($sql_servername, $con);
    $sql="INSERT INTO accounts (Username, Password, Email, SecurityQ, SecurityA) 
    VALUES ('$_POST[username]','$_POST[password1]','$_POST[email1]','$_POST[securityq]','$_POST[securitya]')";
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo ("Hello " . $_POST["username"] . " , welcome to The School Truck."); 
    mysql_close($con);
    //Code here...
    //Code here...
    //Code here...
    //Code here...
    ?>
    What is the problem? I was also thinking maybe i wrote the include line wrong..

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: include & mysql_connect() error.

    don't root the file on the include.... It's going back up to your root (public_html) folder... that's not where you want to go. remove the leading / from the path, and MAKE sure that the folder is Includes and not includes....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: include & mysql_connect() error.

    Oh i will keep that in mind for the future, thank you it works.

Posting Permissions

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



Click Here to Expand Forum to Full Width