Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> I Have An Error With My Mysql Connection, mysql connection error
LacrosseMS
post Jun 17 2008, 08:10 PM
Post #1


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 1
Joined: 17-June 08
Member No.: 31,013



ok so here's my web page...

http://lacrossems.t35.org/

it only lags cause its trying to connect to the my sql server...i followed this guide

http://forum.ragezone.com/showthread.php?t=387249

and when i edit my config.php to my host and login info i always get the error cannot connect to the database

here is my config.php if you can help me

CODE
<?php
$host['naam'] = 'CENSORED';                // my host
$host['gebruikersnaam'] = 'righto';       // my database username
$host['wachtwoord'] = 'CENSORED';   // my database password
$host['databasenaam'] = 'odinms';       // my database name

$db = mysql_connect($host['naam'], $host['gebruikersnaam'], $host['wachtwoord']) OR die ('Cant connect to the database');
mysql_select_db($host['databasenaam'], $db);

$serverip = "CENSORED";     //Replace with your WAN IP if public
$loginport = "8484";         //Don't change
$sql_db = "odinms";             //DB Name
$sql_host = "CENSORED";     //DB Host
$sql_user = "righto";              //DB User
$sql_pass = "CENSORED";                  //DB Password
$logserv_name = "<b>Server</b>: ";         //Status Server Name
$offline = "<s>Offline</s>";  //Displays Offline Status
$online = "<u>Online</u>";    //Displays Online Status
?>
<?php
if ($row['job']=="510")
echo "SuperGM";
if ($row['job']=="500")
echo "GM";
if ($row['job']=="000")
echo "Beginner";
if ($row['job']=="100")
echo "Warrior";
if ($row['job']=="110")
echo "Fighter";
if ($row['job']=="120")
echo "Page";
if ($row['job']=="130")
echo "Spearman";
if ($row['job']=="111")
echo "Crusader";
if ($row['job']=="121")
echo "White Knight";
if ($row['job']=="131")
echo "Dragon Knight";
if ($row['job']=="112")
echo "Hero";
if ($row['job']=="122")
echo "Paladin";
if ($row['job']=="132")
echo "Dark Knight";
if ($row['job']=="200")
echo "Magician";
if ($row['job']=="210")
echo "Wizard";
if ($row['job']=="220")
echo "Wizard";
if ($row['job']=="230")
echo "Cleric";
if ($row['job']=="211")
echo "Mage";
if ($row['job']=="221")
echo "Mage";
if ($row['job']=="231")
echo "Priest";
if ($row['job']=="212")
echo "Arch Mage";
if ($row['job']=="222")
echo "Arch Mage";
if ($row['job']=="231")
echo "Bishop";
if ($row['job']=="300")
echo "Bowman";
if ($row['job']=="310")
echo "Hunter";
if ($row['job']=="320")
echo "Crossbowman";
if ($row['job']=="311")
echo "Ranger";
if ($row['job']=="321")
echo "Sniper";
if ($row['job']=="312")
echo "Bow Master";
if ($row['job']=="322")
echo "Crossbow Master";
if ($row['job']=="400")
echo "Thief";
if ($row['job']=="410")
echo "Assassin";
if ($row['job']=="420")
echo "Bandit";
if ($row['job']=="411")
echo "Hermit";
if ($row['job']=="421")
echo "Chief Bandit";
if ($row['job']=="412")
echo "Nights Lord";
if ($row['job']=="422")
echo "Shadower";
?>


how can i get it to connect to my database correctly to create accounts and such?
Go to the top of the page
 
+Quote Post
wutske
post Jun 18 2008, 07:29 AM
Post #2


Way Out Of Control - You need a life :)
Group Icon

Group: [HOSTED]
Posts: 1,025
Joined: 2-August 05
From: Kapellen (Antwerp, Belgium)
Member No.: 7,585



In 99% percent of the cases, your host is localhost

CODE
$host['naam'] = localhost;


and instead of just returning some text in case of an error, die with this:
CODE
die(mysql_error())


Also, the link to your website isn't working.
Go to the top of the page
 
+Quote Post
Feelay
post Jun 18 2008, 07:02 PM
Post #3


Kinda N00B
Group Icon

Group: Members
Posts: 220
Joined: 13-January 08
From: Sweden
Member No.: 27,579



like wutske said:
if you change the
CODE
OR die ('Cant connect to the database');
to
CODE
OR die (mysql_error());
you will get more information about what's wrong with your code.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jun 19 2008, 08:22 AM
Post #4


Super Member
Group Icon

Group: [HOSTED]
Posts: 750
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



I think that this error happens because of the server name parameter, as wutske said use localhost instead.

The database server name parameter is a string that can include the port number the MySql server will use in case it is necesary. Also, you can use a path to a local socket ":/path/to/socket" for the localhost or even an IP number. So, the following ones are valid strings which you can use to specify your MySql server name:
  • localhost
  • localhost:3306
  • example.com
  • example.com:3307
  • /tmp/mysql.sock
  • localhost:/tmp/mysql.sock
  • 127.0.0.1
  • 127.0.0.1:3306
For more information visit the mysql_connect() php function page, and if you need the exactly mysql error number use the mysql_error() function, like:

CODE
<?php
$db = mysql_connect($host['naam'], $host['gebruikersnaam'], $host['wachtwoord']) OR die("Mysql Error: " . mysql_errno() . " - " . mysql_error());
?>

Generally i use a function when i need to connect to any database, and instead using the die() php function i use the exit() php function when an error is generated. Here is my general database connection function:

CODE
<?php
function dbconn($server,$uname,$upwd,$dbname) {
    if(!($link=mysql_connect($server,$uname,$upwd))) {
        $errorText = mysql_error();
        $errorNum = mysql_errno();
        echo "Connection to the database server fails.<br />MySql says:<br />Error Number: $errorNum<br />Error Message: $errorText";
        exit();
    }
    if (!mysql_select_db($dbname,$link)) {
        $errorText = mysql_error();
        $errorNum = mysql_errno();
        echo "Database selection fails.<br />MySql says:<br />Error Number: " . $errorNum . "<br />Error Message: " . $errorText";
        mysql_close();
        exit();
    }
    return $link;
}

$host['naam'] = 'CENSORED';                // my host
$host['gebruikersnaam'] = 'righto';       // my database username
$host['wachtwoord'] = 'CENSORED';   // my database password
$host['databasenaam'] = 'odinms';       // my database name

// To connect you can use this way
$conn = dbconn($host['naam'],$host['gebruikersnaam'],$host['wachtwoord'],$host['databasenaam']);

// or this way too
dbconn($host['naam'],$host['gebruikersnaam'],$host['wachtwoord'],$host['databasenaam']);
?>

Best regards,
Go to the top of the page
 
+Quote Post
Heave Projects
post Jun 21 2008, 06:53 PM
Post #5


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 8
Joined: 21-June 08
Member No.: 31,090



This webpage redirects to an ad-page?
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jun 22 2008, 08:52 PM
Post #6


Super Member
Group Icon

Group: [HOSTED]
Posts: 750
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



Yes it is, the first url opens an ad-page so don't waste your time visiting it, only the second url is useful.

Best regards,
Go to the top of the page
 
+Quote Post
darkken
post Jul 2 2008, 09:29 PM
Post #7


Newbie [ Level 2 ]
Group Icon

Group: [HOSTED]
Posts: 26
Joined: 2-July 08
Member No.: 31,263



So it looks like the problem is fixed? I checked your web site and only got ads.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jul 4 2008, 09:12 PM
Post #8


Super Member
Group Icon

Group: [HOSTED]
Posts: 750
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



We don't have the choice to know if the problem is fixed, because the starter user of this topic don't say anything but It seems that the problem is fixed.

Best regards,
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. MySQL - Trouble With Bulk Insert Statements(3)
  2. MySQL Realtime Replication(4)
  3. Recover Tables From A MySQL .frm File(8)
  4. Mirror My MySQL Database To Another Mysql Server(4)
  5. How To Connect MySQL With Flash?(8)
  6. MySQL Output Database Question(18)
  7. MySQL, Multiple Tables(24)
  8. Navcat For MySQL(8)
  9. Permission Problem With Mysql Database Creation(8)
  10. Mysql And Php(15)
  11. Problems With Php Saving Data Into Mysql(6)
  12. Login System Using A Mysql Db(5)
  13. Oracle Vs. Mysql Vs. Postgresql(9)
  14. Subqueries In Mysql(1)
  15. Apache Php With Mysql On Windows [solved](9)
  1. Sql Syntax Error [corrected](2)
  2. Not Understanding Mysql(4)
  3. Mysql Script Help(3)
  4. Mysql - So Hard(14)
  5. Mysql Problem(1)
  6. Sun Bought Mysql(6)
  7. Mysql Backup With Another Address?(4)
  8. Mysql And User File_priv(0)
  9. Mysql Database Management(1)
  10. Mysql Database Entry By Excel Sheets(2)
  11. Mysql On Computer(9)
  12. Any Website Provide Free Host Mysql Host?(4)
  13. Mysql Multiple Tables(1)


 



- Lo-Fi Version Time is now: 7th September 2008 - 10:51 PM