Ask Experts Questions for FREE Help!
  Advanced
Register  |  Log in  
   Ask    
 Answer  
  Help  

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Computers & Technology > Programming > Scripting > PHP   »   Connecting to MySQL with PHP on Apache 2.2

 
Thread Tools Display Modes
Question
 
 
#1  
Old Mar 6, 2007, 06:43 AM
sypher373
Full Member
sypher373 is offline
 
Join Date: Feb 2007
Posts: 361
sypher373 See this member's comment history on his/her Profile page.
Hello all,

Just a little background on my system.

I am running Windows XP Pro SP2. Firewall is disabled.

Running Apache 2.2, PHP5 and MySQL server 5.1.

I am trying to simple interface with my MySQL database using a webpage running PHP. I have tried using the mysql_connect(host, name, password) function, checked all the parameters 50,000 times and I still cannot connect. As a test, I wrote a small script that resembled this:

<?php

echo "start";
mysql_connect($host, $name, $pass);
echo "end";

?>

The problem with that is, only the "start" printed. I have no indication that I ever got connected to the database, as the insertion of a create db command yielded nothing. I have even tried the connection function using the 'or die("Error"); part. No error, no connection.

MY firewall is turned off, MySQL operates fine at the command line, and apache is working fine. All PHP commands work, i just cant seem to interface with MySQL.

Any suggestions??

I forgot to mention, this is all being run on the same machine, making my hostname localhost. I have tried localhost as well as 127.0.0.1

Reply With Quote
 
     

Answers
 
 
Old May 10, 2007, 10:25 PM   #2  
Junior Member
BenReilly is offline
 
Join Date: Dec 2006
Location: Canada
Posts: 51
BenReilly See this member's comment history on his/her Profile page.
Try the following:
<?PHP
$db_server = 'localhost';
$db_name = 'whateveritis';
$db_user = 'root';
$db_passwort = 'password';

$db = @mysql_connect($db_server, $db_user, $db_passwort)
or die ('The Connection could not be established');

$db_check = @mysql_select_db($db_name);

if($db)
echo 'Connection to Database is established';
?>
If you are connected to the db you will receive the last message.
  Reply With Quote
 
     
 
 
Old Jan 11, 2008, 02:48 PM   #3  
Junior Member
interinfinity is offline
 
Join Date: Jan 2008
Location: Louisiana
Posts: 143
interinfinity See this member's comment history on his/her Profile page.
make sure mysql services running in services.msc, try restarting apache and msql servies
  Reply With Quote
 
     


Thread Tools
Display Modes

 
Similar Sponsors

Similar Threads
Question Asker Forum Answers Last Post
PHP5 MySQL Hosting Ademan Hosting 11 May 6, 2008 12:38 PM
His Apache Name Pitter History 3 Dec 28, 2006 04:28 AM
Help in PHP extension john_christopher_s PHP 1 Mar 30, 2006 02:19 AM
CGI for Apache - Premature end of script headers ungureaa Internet & the Web 13 Dec 26, 2005 12:10 PM
Apache User Authentication issue. help F1_Fan Internet & the Web 7 Jun 9, 2005 11:31 AM




Copyright ©2003 - 2007, Ask Me Help Desk.
All times are GMT -8. The time now is 05:34 PM.