By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,288 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

Hlep with w2k LAMP configuration, I think.

P: n/a

Is there a usenet group for Apache questions? If I knew of one I'd
post the question there.

I can't get a MySQL connection in PHP code under apache to work.

I'm learning LAMP, starting on a w2k box. I've downloaded recent
copies of Apache, MySQL and PHP and done the setup and it seems to
work,except for SQL. I can run pure PHP under the apache server and
I've installed phpmyadmin and I can make a database and then access it
from mysql in a cmd shell.

I suspect there is some configuration in Apache to talk to Mysql that
I've missed. There is no explicit mention of MySQL in my httpd.conf.

This code is my index.php file, generated from Dreamweaver8. When I
put it on my server and try to hit it from my browser (Firefox) it
just hangs and times out. Any other file (like index.htlm) works
fine, and a ling on index.html to index.php also hangs. All the
passwords, etc, work when tested from command line mysql.

I watch the Apache transaction log and see the client server activity.
There is none when I type to execute this code.

/Connections/apress.php is where it's supposed to be and the contents look fine.
It was generated by DW.

Thanks.

---index.php---

<?php virtual('/index.php/Connections/apress.php'); ?>
<?php
mysql_select_db($database_apress, $apress);
$query_rstCDS = "SELECT cd_name FROM cd";
$rstCDS = mysql_query($query_rstCDS, $apress) or die(mysql_error());
$row_rstCDS = mysql_fetch_assoc($rstCDS);
$totalRows_rstCDS = mysql_num_rows($rstCDS);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My CD collection</title>
</head>

<body>
<p>&nbsp;</p>
<p>My CD COllection</p>
<p>&nbsp;</p>
<p><?php echo $totalRows_rstCDS ?> Records in our colleciton</p>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($rstCDS);
?>


--
a d y k e s @ p a n i x . c o m

Don't blame me. I voted for Gore.
Mar 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Following on from Al Dykes's message. . .


I suspect there is some configuration in Apache to talk to Mysql that
I've missed. There is no explicit mention of MySQL in my httpd.conf.


(1) Apache needs to know about php
(2) PHP needs to know about MySQL
From this analysis you can see that it is the php.ini file where you
should be looking. Version 5 needs MySQL enabling whereas version 4 was
enabled by default. (I can't give the details at the moment - look in
the V5 docs)

--
PETER FOX Not the same since the e-commerce business came to a .
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Mar 8 '06 #2

P: n/a
Al Dykes wrote:
Is there a usenet group for Apache questions? If I knew of one I'd
post the question there.

How about alt.apache.configuration?
I can't get a MySQL connection in PHP code under apache to work.

Not good. :-)
I'm learning LAMP, starting on a w2k box. I've downloaded recent
copies of Apache, MySQL and PHP and done the setup and it seems to
work,except for SQL. I can run pure PHP under the apache server and
I've installed phpmyadmin and I can make a database and then access it
from mysql in a cmd shell.

Then MySQL and PHP ARE working together.
I suspect there is some configuration in Apache to talk to Mysql that
I've missed. There is no explicit mention of MySQL in my httpd.conf.

You shouldn't need it in the httpd.conf file. Apache isn't accessing
MySQL - PHP is. But it does need to be in your php.ini file.
This code is my index.php file, generated from Dreamweaver8. When I
put it on my server and try to hit it from my browser (Firefox) it
just hangs and times out. Any other file (like index.htlm) works
fine, and a ling on index.html to index.php also hangs. All the
passwords, etc, work when tested from command line mysql.

Hmmm, that doesn't sound good :-) I watch the Apache transaction log and see the client server activity.
There is none when I type to execute this code.

What about the Apache error log? And your MySQL log? Anything there?

Also - did you actually connect to the host in your include file? Since
you didn't post it, we don't know.

If you can't find any errors, you may have to back up and do some
troubleshooting. Like comment out all the MySQL code except the call to
connect and try. If it works, add the db selection, and so on.
/Connections/apress.php is where it's supposed to be and the contents look fine.
It was generated by DW.

I never trust generated code. I use it, but not without examining it
very closely first. I've been burned too many times. Congratulations
for checking it!
Thanks.


<code snipped>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Mar 8 '06 #3

P: n/a
In article <dY********************@comcast.com>,
Jerry Stuckle <js*******@attglobal.net> wrote:
Al Dykes wrote:
Is there a usenet group for Apache questions? If I knew of one I'd
post the question there.


How about alt.apache.configuration?
I can't get a MySQL connection in PHP code under apache to work.


Not good. :-)
I'm learning LAMP, starting on a w2k box. I've downloaded recent
copies of Apache, MySQL and PHP and done the setup and it seems to
work,except for SQL. I can run pure PHP under the apache server and
I've installed phpmyadmin and I can make a database and then access it
from mysql in a cmd shell.


Then MySQL and PHP ARE working together.
I suspect there is some configuration in Apache to talk to Mysql that
I've missed. There is no explicit mention of MySQL in my httpd.conf.


You shouldn't need it in the httpd.conf file. Apache isn't accessing
MySQL - PHP is. But it does need to be in your php.ini file.

Thanks for you comments. I've gutted the Dreamweaver code and reduced
the problem to textbook code;
<?php
@mysql_connect("localhost", "book2", "book2")
or die("Could not connect to MySQL server!");

@mysql_select_db("book2")
or die("Could not select database!");
?>

It works and I'm on to other problems. I'll deal with DW later. I'll
deal with dreamweaver later.
--
a d y k e s @ p a n i x . c o m

Don't blame me. I voted for Gore.
Mar 8 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.