#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Georgia
    Posts
    3
    Rep Power
    0
    Below is the code for one of my PHP3 scripts. Now, I have gone through this site and it kinda makes sense, except for a few things at least. Mainly, why won't mine work?

    Now I used the tutorial scripts to test out trying to access a table in my database and display it on a web page. Now, this is where I begin having problems. It seems, first off, my database is not being accessed.

    Second, the include feature of PHP3 does not seem to work for me either. I used this code to test the include:

    ---Begin Code---
    <script language="php">
    echo ("some editors (like FrontPage) don't
    like processing instructions");
    include("test.txt");
    </script>
    ---End Code---

    test.txt simply says "testing the include function" in the file. Nothing appears when I load the page. Not only this, whenever I load the PHP3 file that holds the script below I get a "File not found" message.

    This is beginning to get to me. At this point I am wondering if PHP3 is even loaded on my server like it is supposed to be. Does anyone have any ideas if I am doing anything incorrectly?

    ---Begin Code---
    <?
    /* script to output to screen all users preferring Apples to Oranges */

    /* declare some relevant variables */
    $hostname = "localhost";
    $username = "myusername";
    $password = "mypassword";
    $userstable = "roster";
    $dbName = "mydatabasename";

    /* make connection to database */
    MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");

    @mysql_select_db( "$dbName") or die( "Unable to select database");

    /* Select all users with the preference Apples */
    $query = "SELECT * FROM $userstable WHERE choice = 'Apples'";

    $result = MYSQL_QUERY($query);

    /* How many of these users are there? */
    $number = MYSQL_NUMROWS($result);

    /* Print these results to the screen in a nice format */
    $i = 0;

    IF ($number == 0) :
    PRINT "<CENTER><P>Nobody in the database prefers Apples!</CENTER>";
    ELSEIF ($number > 0) :
    PRINT "<CENTER><P>Users preferring Apples: $number<BR><BR>";
    WHILE ($i < $number):
    $name = mysql_result($result,$i,"name");
    $email = mysql_result($result,$i,"email");
    PRINT "Visitor $name likes Apples.<BR>";
    PRINT "Email address: $email.";
    PRINT "<BR><BR>";
    $i++;
    ENDWHILE;
    PRINT "</CENTER>";
    ENDIF;
    ?>
    ----End Code----




    ------------------
    Pacer - A Poor, Befuddled Fool..
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 1999
    Location
    Denmark
    Posts
    83
    Rep Power
    15
    Hi

    If you do not know if PHP is running or not, then mahe a script like this, and nothing else:

    <? echo PHPINFO(); ?>

    Save the file, and call it from your browser.


    ------------------
    regds..
    -ulrik-

  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Georgia
    Posts
    3
    Rep Power
    0
    File Not Found....hmmm. : ) Does that mean its not installed? I am beginning to guess yes.

    Thanks for the help!


    ------------------
    Pacer - A Poor, Befuddled Fool..
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    No, it means "file not found".

    If php isn't installed you would get the unparsed content of the file. In this case your browser would have:

    <? echo PHPINFO(); ?>

    (BTW, the correct way to do that is

    <? PHPINFO() ?>

    Notice, no echo)

    File not found means that you are not providing the correct path to the file, or (same thing said differently), your file isn't in the directory you say it is, in the address line of the browser.


    [This message has been edited by rod k (edited January 06, 2000).]
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Georgia
    Posts
    3
    Rep Power
    0
    But the file is showing up in the directory and file structure. Boy, no I REALLY am confused. Hehe


    ------------------
    Pacer - A Poor, Befuddled Fool..
  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    How are you calling the file? Is this on your local computer?

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 03:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo