-
April 28th, 2005, 05:59 PM
#1
Senior Member
PHP Doesn't see MySQL server :(
Hi!
I'm trying to run an apache server from my system with PHP and MySQL.
For some strange reason, PHP doesn't register that MySQL is running on my system. Going through tutorials didn't tell me much.
Any pointers as to what should I look at?
P.S. For "Google" people. I already searched and all I need is pointers for further searches
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 28th, 2005, 06:01 PM
#2
Check your config file...can you post the error?
There are only two kinds of programming languages: those people always bitch about and those nobody uses.
-
April 28th, 2005, 06:01 PM
#3
What OS are the two running on? Are they on the same box? Are you sure MySQL is running? If its a linux type system try netstat -antp and look for mysql listening on a port. Other than that I think we need a little more information about how you have things setup.
-
April 28th, 2005, 06:09 PM
#4
Senior Member
Sorry my fault.
They both run on the same XP machine.
I tryed <? phpinfo(); ?>
It doesn't show MySQL. Not sure what might be grong with them.
I'm looking in to other things as well.
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 28th, 2005, 06:12 PM
#5
Senior Member
Another thing.
MySQL runs as Windows service. I can easily conect to it through the comand line
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 28th, 2005, 06:30 PM
#6
There are only two kinds of programming languages: those people always bitch about and those nobody uses.
-
April 28th, 2005, 07:42 PM
#7
Senior Member
Thanks for the tutorial, but I don't think it'll do me much good. the thing is that I can conect to the server if I'm conecting from the comand line. The problem is that PHP doesn't register MySQL server.
I can't anderstand why
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 28th, 2005, 09:00 PM
#8
Senior Member
OK. I got one of the tools running. It shows that PHP actualy does contact MySQL server. Only it doesn't seem to produce any output on the page.
that's the code I use. IT should be alright. although a second opinion would be apriciated
<html>
<head>
<titlte></title>
</head>
<body>
<?php
$host = "127.0.0.1:3306";
$user = "php";
$password = "*******";
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to a server");
$db = mysql_select_db("tourism", $connection)
or die ("Couldn't find database");
$query ="SELECT FROM hotels";
$result = mysql_query ($query)
or die ("couldn't execute");
if(!$result) die("Query Failed.");
$num = mysql_numrows($result);
mysql_close($connection);
$count = 0;
while ($count < $num) {
$hotelID=mysql_result($result,$i,"Hotel_ID");
$hotelName=mysql_result($result,$i,"Hotel_Name");
echo "<b>$hotelID $hotelName</b";
$count++;
}
?>
</body>
</html>
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 28th, 2005, 09:08 PM
#9
Senior Member
I also used "$host = "localhost";
Don\'t post if you\'ve got nothing constructive to say. Flooding is annoying
-
April 28th, 2005, 09:35 PM
#10
Hey Hey,
So it sounds to me like your mysql and php are playing quite well together.
As far as phpinfo() goes, it doesn't connect to mysql... it's a function that displays statistics about your machine and php... It may tell you if php was built with --enable-mysql or whatever the configure option is, but that's about it.
As far as your script, you've got errors in your mysql syntax... SELECT FROM hotels will not return any results... you must tell it which columns you wish to select... by specifying names (firstname, lastname, roomnumber... whatever you have in your database)... or by * to select all columns.
Peace,
HT
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|