Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Help (http://www.go4expert.com/forums/help-t6020/)

Pyramid Games Ltd. 25Aug2007 00:54

Help
 
Warning: require_once(DbConnector.php) [function.require-once]: failed to open stream: No such file or directory in /home/zendurl/public_html/p/program5/signup.php on line 21

Fatal error: require_once() [function.require]: Failed opening required 'DbConnector.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/zendurl/public_html/p/program5/signup.php on line 21

The file (signup.php):
PHP Code:

<form action="signup.php?submit" class='form colours' method='POST'>
    <fieldset>
        <legend>Join Programmer's Space</legend>
            <p align='right'>Username: <input name='username' size='25' maxlength='25' /></p>            
            <p align='right'>Password: <input name='password' size='25' maxlength='25' /></p>    
                        <p align='right'><input type='submit' value='Submit' /></p>
    </fieldset>
</form>
<?php
// Check if the form has been submitted
if(isset($_GET["submit"]))
{
    if(isset(
$_POST["username"]) && isset($_POST["password"]))
    {    
        
//Username or password is not blank
        
if($_POST["username"]!="" && $_POST["password"]!="")
        { 
// Everything is ok add the user to the database
 
            // Connect to the database
            
require_once("DbConnector.php");   // Include the database class
            
$db = new DbConnector();               // Create an instance of the database class
            
$db->connect();                               // Connect to the database
            
$query "SELECT * FROM members WHERE username='".$_POST["username"]."'";
            
$result $db->query($query);
            
$result mysql_num_rows($result);
 
            if(
$result!="0")
                echo 
"Username already exists!";
            else 
            { 
                
// Create a query that inserts the data from the form to the database
                
$query "INSERT INTO members(username,password) VALUES('".$_POST["username"]."','".$_POST["password"]."')";
 
                
$result $db->query($query);
                echo 
"Signed up succesfully you can now <a href=\"login.php\">log in</a>";
            }
        }
        else 
        {
            echo 
"Error: No username or password supplied, try again.";
        }
 
    }
    else 
        echo 
"Error: please fill in the <a href=\"signup.php\">signup form</a>";
}
?>

DBConnector.php
PHP Code:

<?php
////////////////////////////////////////////////////////////////////////////////////////
// Class: DbConnector
///////////////////////////////////////////////////////////////////////////////////////
require_once 'DbVars.php';
 
class 
DbConnector extends Dbvars {
 
        var 
$theQuery;
        var 
$link;
  var 
$dbname;
  var 
$host;
  var 
$user;
  var 
$pass;
    
   function 
DbConnector(){
        
// Load settings from parent class
        
$settings Dbvars::getSettings();
        
// Get the main settings from the array we just loaded
        
$this->host $settings['dbhost'];
        
$this->dbname $settings['dbname'];
        
$this->user $settings['dbusername'];
        
$this->pass $settings['dbpassword'];
    }
  
   function 
setDatabase($ndbname)
  {
    
$this->dbname $ndbname;
  }
  
  function 
connect()
  {
                 
// Connect to the database
                 
$this->link mysql_connect($this->host$this->user$this->pass)or die(mysql_error());
                 
mysql_select_db($this->dbname);
  }
 
    function 
query($query) {
 
        
$this->theQuery $query;
        
$res mysql_query($query$this->link)or die(mysql_error());
  return 
$res;
 
    }
 
    function 
fetchArray($result) {
 
       return 
mysql_fetch_array($result);
 
    }
 
}
?>


pradeep 25Aug2007 13:12

Re: Help
 
The problem is with the location of DBConnector.php, either copy it to the same folder as the othe file of provide the full path to DBConnector.php

shabbir 25Aug2007 18:20

Re: Help
 
Try giving better titles and that would give you better responses. I would suggest you read Before you make a query.


All times are GMT +5.5. The time now is 18:53.