LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Apache Mysql Php: mysql with php doesn't work (https://www.linuxquestions.org/questions/linux-networking-3/apache-mysql-php-mysql-with-php-doesnt-work-128727/)

breakerfall 12-24-2003 06:57 PM

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

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:

Code:

<html>
<head>
<title></title>
</head>

<body>
<?php
 $connection = mysql_connect("localhost","root","")
 or die("sorry - unable to connect to MySQL");
 echo("Congrats - it's working");
?>
</body>
</html>

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:

Quote:

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:

Quote:

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.

-Kilka

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:
Code:

'./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

-Kilka

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.

-Kilka

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.