Configuring PHP 4 to work with MySQL


Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: Configuring PHP 4 to work with MySQL

  1. #1
    Join Date
    Dec 2003
    Posts
    4

    Configuring PHP 4 to work with MySQL

    I'm having a problem. I am using RedHat 9.0 with the basic server instalation. I have gotten Apache up and running and now I am trying to install phpBB2 forums on my server but the problem is I can't get php to access MySQL. I didn't install PHP myself, it was with the instalation on RedHat but I did download and try instaling PHP and unfortunatly, I didn't have the compliers required to do so. So basicly doing the ./config --with-mysql option won't work for me. Does anybody have a solution or could you offer any insight on how I might get this to work?

  2. #2
    Join Date
    Aug 2002
    Location
    FDR India
    Posts
    340
    Hi

    Did you install all the RPMs?

    Search on Google for all the RPMs you need to install (or) use your Red Hat CDs and install all RPMs including the *-devel RPMs too.

    BTW, do you have a working Apache?

    regards
    akr
    O Nobly Born, be thou grave and courteous in thy speech; quick to succour and slow to flame.
    --- Registered Linux User #293167 ---

  3. #3
    Join Date
    Dec 2003
    Posts
    4
    Thanks for the quick response! Yes, Apache is working, PHP is working, and MySQL is working, just they're not working together. I've tried to install the necesary files so that I could compile my own PHP using the --with-mysql argument but I can't seem to get that to work either (keep getting errors for dependicies and when I try to install the dependicies they have dependencies ans so on and so forth). If anybody could let me know where to get the necesary RPMs that would be great. Thanks again!

  4. #4
    Join Date
    Aug 2002
    Location
    FDR India
    Posts
    340
    Hi

    Download synaptic-0.42-1.fr.src.rpm. Synaptic is a front-end to Apt.

    Install as root. Its very easy to use.

    regards
    akr
    O Nobly Born, be thou grave and courteous in thy speech; quick to succour and slow to flame.
    --- Registered Linux User #293167 ---

  5. #5
    Join Date
    Dec 2003
    Posts
    4
    Well, I managed to get ProgreSQL working with PHP (I think) by restarting Apache. I don't get the configuration error anymore, now I get:

    Warning: pg_connect() unable to connect to PostgreSQL server: FATAL: user "apache" does not exist in /web/phpBB2/db/postgres7.php on line 79
    phpBB : Critical Error

    Could not connect to the database
    That's when I try to access the DB through PHP in phpBB2. I have tried different usernames, passwords, creating new ones, making a new DB, but I still can't connect. I'm sure there's something I'm doing wrong but I can't figure it out. Thanks again for all your help.

  6. #6
    Join Date
    Aug 2002
    Location
    FDR India
    Posts
    340
    Hi

    Please post the relevant lines of code from 'postgres7.php'. Lets see if we can indentify the problem

    regards
    akr
    PS: when ever you're posting a problem with your code, make sure you post the problem-causing code too.
    O Nobly Born, be thou grave and courteous in thy speech; quick to succour and slow to flame.
    --- Registered Linux User #293167 ---

  7. #7
    Join Date
    Dec 2003
    Posts
    4
    Thanks, but I managed to fix it! Turns out I needed to allow tcp/ip connections in the PostgreSQL config file as well as set my IP address to host. Everything works great now (except my server sucks and I start lagging with 20 users online, but that's not Linux's fault). Thanks again, I didn't think I'd ever get this thing working.

  8. #8
    Join Date
    May 2003
    Posts
    220
    im also trying to get PHP to work with MYSQl

    i have my webserver with PHP and apache installed then i have my database server wtih mysql. im trying to connect them together using php

    how would i go about doing this any good documents for connecting two servers ?

  9. #9
    Join Date
    Nov 2002
    Location
    nyc
    Posts
    35
    to see whether php was installed with mysql support, try creating a file, call it test.php, with the following:

    PHP Code:
    <?php 
    phpinfo
    (); 
    ?>
    then load the file in your browser -- scroll down and look for mysql.

    if its there, then chances are you didn't create a user with appropriate permission for the mysql database the phpbb (or whatever app you're using).

    if you're new to mysql, i'd recommend using phpmyadmin. it's relatively quick and easy to set up. just read the config instructions.

    also, what version of apache are you using? if php is not configured to support mysql, you may need/want to download the apache source files.... not sure though. i needed them, but i installed the latest version of apache, php, mysql and openssl from source on a debian platform. it was actually quite easy too. maybe thats worth a shot.

    hope this (rambling) was helpful...

  10. #10
    Join Date
    May 2003
    Posts
    220
    yeah i have two server machines i want one with php,apache, and the other server to run mysql .....
    im running

    apache 1.3.29

    and i compiled it and it works
    and compared php

    how do i compile php to work with my mysql server becasuse php when compliled u have to tell give it the path to the mysql database

    ./configure --with-mysql=/path --with-apxs=path


    i run slackware 9.1 on both machines

    thanks

  11. #11
    Join Date
    Nov 2002
    Location
    nyc
    Posts
    35
    i'm not sure. when i compiled it, i used the --with-mysql tag without specifying the path. i think, in that case, php compiles with internal mysql headers. perhaps that's worth a try for you.

    also, did you try phpinfo()? that way you can confirm that the php install is the problem and not your mysql user.

  12. #12
    Join Date
    May 2003
    Posts
    220
    yes i did that and it works
    php is working mysql and apache

  13. #13
    Join Date
    Nov 2002
    Location
    nyc
    Posts
    35

    Thumbs up

    fantastic! hope i helped! have fun with it!

  14. #14
    Join Date
    May 2003
    Posts
    220
    im getting this error when i try to connect to the mysql server

    Warning: mysql_connect(): Host '192.168.1.104' is not allowed to connect to this MySQL server in /www2/installed/apache_1.3.29/htdocs/db_connect.php on line 2
    Host '192.168.1.104' is not allowed to connect to this MySQL server

  15. #15
    Join Date
    Nov 2002
    Location
    nyc
    Posts
    35
    ah. now again, i'm not sure as i'm pretty new to this too, but when you create a user to connect to the database, you have to select the host. if you don't, it either defaults to 'localhost' or the pc's hostname. you might try reconfiguring the user and specify the host as '192.168.1.104'.

    this page might be helpful (http://www.mysql.com/doc/en/Adding_users.html). i find phpmyadmin incredibly helpful (considerably les comlicated) with these things though.

Posting Permissions

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