Jump to content

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