You are not logged in.

#1 2009-01-06 01:42:45

Kronophage
Member
From: Liege, Belgium
Registered: 2008-07-23
Posts: 9

LAMP config : mysql access from php [god-solved]

Hi guys.

So i've got this nice book about PHP/MySQL programming.

I have just installed apache/php/mysql, using the LAMP guide on the wiki.
I think i got it OK.

* httpd starts
* mysqld starts
* the test.php with the phpinfo() call works
* i can play with my database using the mysql utility

Here is the problem :
when trying a simple php script to access mysql, i get a blank page.

here is an exerpt of the script :

[...]
<?php
    require ("Connect.php");

    echo "apres require<br/>";      (1)

    $connexion = mysql_pconnect ("SERVEUR", "NOM", "PASSE");
    if (!connexion)
    {
        echo "Désolé, connexion à " . SERVEUR . " impossible\n";     (2)
        exit;
    }

    echo "apres connexion<br/>";   (3)
[...]

The first echo (1) is printed, while the second (2) and the third (3) aren't, so it looks like it's stuck at the mysql_pconnect call.
(the SERVEUR (localhost), NOM, PASSE variables are set in the Connect.php file and they are correct)

I'm guessing there is a permission issue.
The thing is, what directory should chmod ? For what user/group ?
Am i mistaken ?

The directory i use for my files is ~/public_html.

I also have about the same question for setting up phpMyAdmin.
When trying to use the http://localhost/phpMyAdmin/setup/index.php script, it says it can't write the config, which is obvious since it is installed in /srv/http/phpMyAdmin which belongs to root.
Should i chown the /srv/http directory or would it be better to make myself part of some group like http or stuff and chgrp it ?

Edit: despite a few warnings and errors on the pages, i can connect to mysql with phpmyadmin out of the box; which confuses me more about the issue with my php script

I'm new to this stuff, so i don't know what info would be relevant to provide.

Thanks in advance for your answers. smile
Cheers
Ed

Last edited by Kronophage (2009-01-06 02:28:00)


Laptop Dell Vostro 1500 : 15''(1440x900), core2duo T7250@2.00Ghz, 2Gb RAM, 160Gb@5400rpm, NVidia 8400M

Offline

#2 2009-01-06 02:04:54

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: LAMP config : mysql access from php [god-solved]

If you're not getting any output, I'd be guessing it's dying before your 'require'. The default php installation is very quiet about it's errors.

Add these lines to /etc/syslog-ng.conf and restart syslog-ng then check the log after you run the script:

destination php     { file("/var/log/php.log"); };

filter f_php        { match("PHP"); };

log { source(src); filter(f_php); destination(php); };

Offline

#3 2009-01-06 02:26:57

Kronophage
Member
From: Liege, Belgium
Registered: 2008-07-23
Posts: 9

Re: LAMP config : mysql access from php [god-solved]

Well...

First, in fact it did enter the php script since it printed the first echo instruction.

But it works now...
I have no idea why since i didn't change anything instead of installing mcrypt for phpmyadmin mad
Or maybe i did something else... s*** i hate that roll

Anyway. big_smile
Thanks for your answer and thanks for the tip about redirecting into a log file, i'm sure it'll come in very handy smile

I hope i can make my way now.
Cheers
Ed


Laptop Dell Vostro 1500 : 15''(1440x900), core2duo T7250@2.00Ghz, 2Gb RAM, 160Gb@5400rpm, NVidia 8400M

Offline

Board footer

Powered by FluxBB