-   Linux - Networking (
-   -   Apache Mysql Php: mysql with php doesn't work (

breakerfall 12-24-2003 06:57 PM

(Resolved) Apache Mysql Php: mysql with php doesn't work

I compiled and installed the latest version of apache, mysql and php just the other day. I have just gotten around to testing to make sure that all 3 work with each other and I did this by creating:



 $connection = mysql_connect("localhost","root","")
 or die("sorry - unable to connect to MySQL");
 echo("Congrats - it's working");

Now if all was working fine I should have seen the "Congrats" message when viewing the file saved as php on apache. I know that the apache is working and that php is working... however when trying to view that partuicular file I get an error message:


Warning: Unknown(/usr/local/apache2/htdocs/index.php): failed to open stream: Permission denied in Unknown on line 0

Warning: (null)(): Failed opening '/usr/local/apache2/htdocs/index.php' for inclusion (include_path='.:/usr/local/lib/php') in Unknown on line 0
Now unfortunately, I'm a php / mysql "know nothing" at the moment (soon to change hopefully) but I'm not sure where to go from this error. I checked the php info file and something strange I noticed is the MySQL section:


Client API version 3.23.49
Now I know 100% that I compiled in the latest mysql which happens to be 4.0.17: so could this be my problem?

Any help really appreciated and merry christmas too :)

Kilka 12-24-2003 09:38 PM

php I think...
I had a problem similar to this. Did you compile php from source or use the rpm ? When you compile it from source, you have to tell it to use mysql so go ./configure --help | grep SQL and you should see something relevant.


breakerfall 12-24-2003 09:40 PM

yeah... I added the relevant switch in compile to make sure it uses MySQL. The phpinfo file shows that I used the switch:

'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-mysql'
Any other ideas... I really want to start learning mysql and php but I need to get this thing sorted first :(

Kilka 12-25-2003 02:34 PM

user login for the SQL server...Have
Have you already created a mySQL account for root ?

run mysql_install_db I think


breakerfall 12-25-2003 02:56 PM

Thanks for the reply Kilka

I had already done this as soon as I had installed and compiled mysql. I can actually access the mysql prompt now doing /usr/local/mysq/bin/mysql -u root -p, it's just that php doesn't seem to be interacting with it. That combined with the phpinfo file showing me that the mysql version is 3.23 which is way out. :|

I guess I'm going to have to remove apache php and mysql and start over... thanks anyway :)

Kilka 12-27-2003 04:48 PM

any luck starting over ?
Let me know if you still have issues starting over.


breakerfall 12-27-2003 09:59 PM

Thanks for keeping an interest :)

The problem has been resolved. When I compiled php I just the switch "--with-mysql" when what I really should have done was "--with-mysql=/usr/local/mysql".. the documentation didn't make me aware of this. I noticed after deciding to re-compile php again and my console window was larger and I saw the very top bit of the end of configure message which mentioned what switch to use if I had installed mysql and didn't want to use phps own builtin mysql.

Again, thanks :)

All times are GMT -5. The time now is 07:31 AM.