Jump to content

cant connect 2 sql???


aconite

Recommended Posts

I am completely new to PHP and mysql.so im having some prob lems in connecting them

i have installed XAMPP1.6.0 (MySql 5.0.33,PHP 5.2.1,Apache 2.2.4). My apache works fine.phpinfo() page is also shown but without any MySql details.but now im trying to run this php file.the browser displays echo statements till "done 4" so im guessing the prob is with mysql_connect.XAMPP shows the mySql service is running. In php.ini file php extention is given.i hav also downloaded libmysql.dll and php_mysqli.dll even that doesnt work.wht should i do

code:

 

<?php

echo 'done2';

// hostname or ip of server (for local testing, localhost should work)

$dbServer='127.0.0.1';

echo 'done2';

 

// username and password to log onto db server

$dbUser='root';

$dbPass='';

echo 'done3';

 

// name of database

$dbName='test';

echo 'done4';

 

    $link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");

 

    echo 'Connected successfully';

 

    mysql_select_db("$dbName") or die("Could not select database");

    print "Database selected successfully<br>";

echo 'done5';

 

// close connection

mysql_close($link);

echo 'donehjk';

?>

Link to comment
Share on other sites

check user name and password is the only answer, check whether you can connect as root without a password( unless that was removed for security reasons - generally if that is the case a few *** are put there to mean you know something should be there but would rather not print it)

 

try this one see what the error is

<?php
$link = mysql_connect($dbServer, $dbUser, $dbPass) or die('Could not connect: ' . mysql_error());
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.