Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 7th, 2006, 07:55 PM
Al Dykes
Guest
 
Posts: n/a
Default Hlep with w2k LAMP configuration, I think.


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.
  #2  
Old March 8th, 2006, 09:05 AM
Peter Fox
Guest
 
Posts: n/a
Default Re: Hlep with w2k LAMP configuration, I think.

Following on from Al Dykes's message. . .[color=blue]
>
>
>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.[/color]

(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 .
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
  #3  
Old March 8th, 2006, 12:45 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Hlep with w2k LAMP configuration, I think.

Al Dykes wrote:[color=blue]
> Is there a usenet group for Apache questions? If I knew of one I'd
> post the question there.
>[/color]

How about alt.apache.configuration?
[color=blue]
> I can't get a MySQL connection in PHP code under apache to work.
>[/color]

Not good. :-)
[color=blue]
> 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.
>[/color]

Then MySQL and PHP ARE working together.
[color=blue]
> 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.
>[/color]

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.
[color=blue]
> 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.
>[/color]

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

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.
[color=blue]
> /Connections/apress.php is where it's supposed to be and the contents look fine.
> It was generated by DW.
>[/color]

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!
[color=blue]
> Thanks.
>[/color]

<code snipped>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #4  
Old March 8th, 2006, 01:35 PM
Al Dykes
Guest
 
Posts: n/a
Default Re: Hlep with w2k LAMP configuration, I think.

In article <dYCdndyUifG-UpPZRVn-rg@comcast.com>,
Jerry Stuckle <jstucklex@attglobal.net> wrote:[color=blue]
>Al Dykes wrote:[color=green]
>> Is there a usenet group for Apache questions? If I knew of one I'd
>> post the question there.
>>[/color]
>
>How about alt.apache.configuration?
>[color=green]
>> I can't get a MySQL connection in PHP code under apache to work.
>>[/color]
>
>Not good. :-)
>[color=green]
>> 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.
>>[/color]
>
>Then MySQL and PHP ARE working together.
>[color=green]
>> 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.
>>[/color]
>
>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.
>[/color]


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.
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles