SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: PHP Help?

  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Help?

    Hello,

    I need help connecting my test db with PHP.
    I know that php is working on my server because when I did that
    echo "Hello world" Thing everything came out ok. Next I created the
    <?php
    mysql_connect ("localhost","root","password")
    or die("cannot connect");
    mysql_connect_db("testdb")
    or die ("can not connect to testdb");
    ?>


    I set this up and test it and it gives me this:

    Fatal Error:call to undefined fuction:mysql_connect: in /var/www/html/test/testdb.php on line 2

    Can someone help me out?
    Its on a red hat 7.2 machine (running Apache)

    Thanks in advance!

  2. #2
    SitePoint Zealot DJHK's Avatar
    Join Date
    Feb 2002
    Location
    Los Angeles, CA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the code should be:
    <?
    mysql_pconnect ("localhost","root","password")
    or die("cannot connect");
    mysql_select_db("testdb")
    or die ("can not connect to testdb");
    ?>
    The InspirAzNz...NetWorK [Down]

  3. #3
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply!

    I did as you said verbatim!

    If fact I copied and pasted and it still gave the same Error!????

    Im lost!

  4. #4
    SitePoint Zealot DJHK's Avatar
    Join Date
    Feb 2002
    Location
    Los Angeles, CA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, sorry...little typo...

    <?
    mysql_pconnect("localhost","root","password")
    or die("Cannot Connect");
    mysql_select_db("testdb") or die("cannot connect to testdb");
    ?>
    The InspirAzNz...NetWorK [Down]

  5. #5
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where was the typo?
    What am I missing?

  6. #6
    SitePoint Zealot DJHK's Avatar
    Join Date
    Feb 2002
    Location
    Los Angeles, CA
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you try the code I just posted? The typo was the space after the mysql_connect.
    The InspirAzNz...NetWorK [Down]

  7. #7
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    does not make a diff.

    Same Error!

    Im lost!

  8. #8
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whether one uses mysql_connect or mysql_pconnect does not make a difference. The coding is correct with:
    PHP Code:
    <?php
    mysql_connect
    ("localhost","root","password")
         or die(
    "cannot connect");
    mysql_select_db("testdb")
         or die(
    "can not connect to testdb");
    ?>
    If that does not work, then your server is not configured properly and PHP cannot communicate with MySQL.

    Check to make sure that everything is set up correctly on your server. Good luck.

    -Colin
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  9. #9
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it seems that mysql support wasnt installed or something..


    btw pconnect and connect are pretty much the same... pconnect is just a "perminant connection"

  10. #10
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys it was something with the install I
    forgot the --with!

    Its up and runnin now!

    Thanks again


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
  •