SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, found the following lines in one of Kevin Yank's tutorials ( Real good staff )
    But anyway this here does not work on my unix-web-server.
    Does anyone of you have any idea where there is the problem?

    include_path='.:/home/xxx/www/phplib'
    include("xyz.php");
    include("zyk.php");

    Thanx for your help, smorb

  2. #2
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Just a guess, but try removing the .: at the start of home and see whether it works.


    Peter

  3. #3
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx Peter, but it doesn't seem to be the solution.
    How about the correct order. Do I have to say:
    include("xxx.php"); first and than
    include_path ...
    or the way round.
    Do I need ; at the end of include_path ?
    and is it include_path = " .. "
    or is it include_path = ' .. '

    Thanx a lot, smorb

  4. #4
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, Find the location to the file.

    Then do the following:

    PHP Code:
    include("/home/username/phplib/xyz.php"); 
    Now, your path is going to be completely different to mine, however, it should work.

    Have a try!

    Peter

  5. #5
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, yes it works, but not correct. It's really strange. He can find the xyz.php file now, but returns an error message from xyz.php ( can not connect to the database.. ) which I did't got before it was in the same dir. with include("xyz.php");
    I'm sure you need the full skript for this problem, here it is:

    This is the xyz.php file

    <?php //xyz.php
    $dbhost = "localhost";
    $dbuser = "username";
    $dbpass = "xxx";
    function dbConnect ($db="") {
    global $dbhost, $dbuser, $dbpass;

    $dbcnx = @mysql_connect ($dbhost, $dbuser, $dbpass)
    or die("Can not connect to the database");
    if (! @mysql_select_db("explorechinadb") ) {
    echo( "<p>Cann not connect...!</p>" );
    exit();
    }
    return $dbcnx;
    }

    and this is the file using it:



    <?php //signup.php

    include("/home/username/www/phplib/xyz.php");



    if (!isset($submitok)):
    ?>


    <html>
    <head>
    <title>Untitled Document</title>
    </head>

    <body bgcolor="#FFFFFF">
    <form method="post" action="<?=$PHP_SELF?>">
    <p>User ID
    <input type="text" name="newid">
    </p>
    <p> Name
    <input type="text" name="newname">
    </p>
    <p>E-Mail
    <input type="text" name="newemail">
    </p>
    <p> Alter
    <input type="text" name="newnotes">
    </p>
    <p>
    <input type="submit" name="submitok" value=" ok ">
    </p>
    </form>

    </body>
    </html>

    <?php
    else:

    dbConnect ('dbname');


    if ($newid=="" or $newname=="" or $newemail=="") {
    error("Eines oder mehere Felder wurden nicht ausgefüllt.\\n".
    "Bitte ausfüllen und nochmal abschicken.");
    }

    //Chech for existing user-ID

    $sql = "SELECT COUNT(*) FROM user WHERE userid = '$newid'";
    $result = mysql_query($sql);
    if (!$result) {
    error(" An error occured");
    }
    if (mysql_result($result,0,0)>0) {
    error(" User name does already exist");
    }

    $newpass = substr(md5(time()),0,6);

    $sql = "INSERT INTO user SET
    userid = '$newid',
    password = PASSWORD('$newpass'),
    fullname = '$newemail',
    notes = '$newnotes'";
    if (!mysql_query($sql)) {
    echo ( "<p>Fehler</p>");
    }


    ...
    the rest is not so important i think

    I'm sure it is just a small error, but I can find nothing. So thank you very much for your help.
    Smorb

  6. #6
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Try changing this line:

    PHP Code:
    or die("Can not connect to the database"); 
    So that it prints out the error:

    PHP Code:
    or die(mysql_error()); 
    Hopefully that should give you more insight into the problem.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  7. #7
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are there anyway that I can say .htaccess file which directories to check out when I include a file in .php?
    And it is cheap operation or expensive one?

    Something like
    in .htaccess
    php_include_path /home/sylow/include/phplibrary

    and in .php
    include("string.class.php");

    thx

  8. #8
    SitePoint Addict
    Join Date
    Feb 2001
    Location
    Shanghai, China
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, just want to say thanx to Kevin Yank, it's working now. Your tutorial about PHP/MySQL is a fantastic help for beginners.
    Alex


Bookmarks

Posting Permissions

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