Jump to content

Archived

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

rallokkcaz

not connecting to mysql server!!

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!

Share this post


Link to post
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... ;)

Share this post


Link to post
Share on other sites
ohh
it still doesn't work thanks for the help tho. :'(
but tommarow im gonna get a hosting package for my site!
thanks for the help!
[move]""""""""""""pieisgood"""""""""""""[/move]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
ok im on a mac i can't download php5

im using a site that uses phpmyadmin
it won't let me connect to database

right now im trying to connect to the database
through dreamweaver.
can any one help?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
carnt help you with dreamweaver

But with your connection problems try checking the server address coz some servers dont use localhost I no mine dont mine is [serverurl.com] just check that one that may be your problem

Hope its some help :)

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

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.