Jump to content

not connecting to mysql server!!


rallokkcaz

Recommended Posts

[code]$dbhost = 'localhost';
$dbusername = '';
$dbpasswd = '';
$database_name = '';

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") 
    or die ("Couldn't connect to server.");
$db = mysql_select_db("$database_name", $connection)
    or die("Couldn't select database.");
?> [/code]
im using phpmyadmin.
i can't seem to connect to the server.
im not typing anything wrong i can't figure it out!
pleeze help!
Link to comment
https://forums.phpfreaks.com/topic/17591-not-connecting-to-mysql-server/
Share on other sites

Change your [b]die()[/b] calls to print out the MySQL error you are receiving:

[code]
<?php

$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd") 
    or die ("Couldn't connect to server: ".mysql_error());
$db = mysql_select_db("$database_name", $connection)
    or die("Couldn't select database: ".mysql_error());

?>
[/code]

Post back with the error you receive... ;)
Have you installed PHP locally on your computer? If you have installed PHP5 and you're on Windows you'll need to enable the php_mysql.dll function. If you have PHP4 then it should work. Also if you are not on Windows you'll need to recompile PHP with the --with-mysql command option.

Could you post more information about your PHP setup.
[quote author=tdnxxx444 link=topic=104306.msg416307#msg416307 date=1155662046]
Looks like you're not connect as any user with any password to any database.  Have you set up these three things on your mysql server?
[/quote]

yes i have i set up a database for users
[code=php:0]
<php

error_reporting(E_ALL);
ini_set('display_errors','on');

    $conn = mysql_connect("localhost" ,"username", "password");
    $db = mysql_select_db("database") or die("Unable to select database");

?>
[/code]
make sure mysql will allow users to connect from the domain the php is on.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.