MySQL Connection Error

08/31/2011 14:47 San-Goku#1
Hey guys..i have a MySQL Error.I have DELETE my.ini & MySQL Admin is GREEN LIGHT.I also have the some problem when im trying to make site & forum.Im using WAMP.Here the pic:


SITE PROB:
[Only registered and activated users can see links. Click Here To Register...]

MySQL Admin GREEN LIGHT:
[Only registered and activated users can see links. Click Here To Register...]

Although my MySQL cannot connect,but i still can open the database:
[Only registered and activated users can see links. Click Here To Register...]

IM BEGGING GUYS,PLEASE HELP...
08/31/2011 15:00 xTwiztedKidx#2
If I remember correctly, You wouldn't be able to open the DB if MySQL was not connecting, And Looks to me that its clearly connecting. Now, on the site problem, I don't use wamp so I can't help you there. Sorry x.X

Also Posting your index.php code may help getting your issue resolved.
08/31/2011 15:04 San-Goku#3
index.php

Quote:
<?php

$p = $_GET['id'];
if ( !empty($p) && file_exists('./web/' . $p . '.php') && stristr( $p, '.' ) == False )
{
$file = './web/' . $p . '.php';
}
else
{
$file = './web/main.php';
}

include $file;
?>
config.php
Quote:
<?php


// generated May 24, 2010 19:25:31



// mysql server details

define('host', 'localhost'); // Your database host

define('user', 'root'); // Your database username

define('pass', 'test'); // Your database password

define('mydbdata', 'my'); // Your database name my

define('mydbacc', 'account'); // Your database name account

define('serveraddress', '5.66.**.***'); // Your Server address

define('serverport', '3306'); // Your serverport

define('mydb', 'my'); // Your my database

define('servername', 'BlackThunder Online'); // Your Server Name

define('imgdir', 'http://5.66.**.***'); // Your Image dir


define('poweredby', '<a href="http://www.*****************/forum" target="_blank">Powered By Elite4Gaming '); // Dont Delete!

// conect to database

@mysql_connect(host, user, pass) or die('<h1>Unable to connect to database server.</h1>');

@mysql_select_db(mydbdata) or die('<h1>Unable to connect to database server.</h1>');



?>
08/31/2011 15:11 xTwiztedKidx#4
Now from the picture i saw before you edited it was that the error was on line 3 so it will be something wrong along this line,
Quote:
$p = $_GET['id'];
try changing this line
Quote:
$p = $_GET['id'];
to
Quote:
$p = $_POST['id'];
and see if that works.
That's all I can really help you with atm. I hope someone can be smarter than me and resolve your problem if mine does not fix it.
08/31/2011 15:12 San-Goku#5
Quote:
Originally Posted by xTwiztedKidx View Post
Now from the picture i saw before you edited it was that the error was on line 3 so it will be something wrong along this line, That's all I can really help you with atm. I hope someone can be smarter than me and resolve your problem.
its ok now...but still cannot connect to db
08/31/2011 15:19 xTwiztedKidx#6
mk just wondering if you tried changing the
Quote:
$p = $_GET['id'];
to
Quote:
$p = $_POST['id'];
and it fixed that error or what you happened to do.

And maybe try changing this
Quote:
define('host', 'localhost'); // Your database host
to
Quote:
define('host', 'hamanchi ip'); // Your database host
Maybe that will work, im not at my computer atm i will be in a min and ill look at my config.php and see if everything looks correct.
08/31/2011 15:24 San-Goku#7
Quote:
Originally Posted by xTwiztedKidx View Post
mk just wondering if you tried changing the

to

and it fixed that error or what you happened to do.

And maybe try changing this

to


Maybe that will work, im not at my computer atm i will be in a min and ill look at my config.php and see if everything looks correct.
same
08/31/2011 15:24 MoŽtalKing#8
new versions of wamp and xampp and appserv not good in mysql connection so use old versions .. like appserv 2.4
08/31/2011 15:27 San-Goku#9
Quote:
Originally Posted by MoŽtalKing View Post
new versions of wamp and xampp and appserv not good in mysql connection so use old versions .. like appserv 2.4
wait..i try
08/31/2011 15:30 King_Arthur#10
Change
PHP Code:
@mysql_connect(hostuserpass) or die('<h1>Unable to connect to database server.</h1>');

@
mysql_select_db(mydbdata) or die('<h1>Unable to connect to database server.</h1>'); 
to
PHP Code:
@mysql_connect(hostuserpass) or die('<h1>Unable to connect to database server.</h1>' mysql_error());

@
mysql_select_db(mydbdata) or die('<h1>Unable to connect to database server.</h1>' mysql_error()); 
This will give you the mysql error code and tell you where it's failing. At the same time, undo any changes xTwiztedKidx suggested that you have made.

EDIT: Since this really isn't a EO PServer question, but a general PHP/MySQL question, this really should have been posted in the thread where you got your site files from. That way we wouldn't have to ask you to put your index.php in there, the creator of the site could also chime in if he's watching his threads, etc.
08/31/2011 15:34 xTwiztedKidx#11
mk, Well Try using this as your config.php

Quote:
<?php


// generated August 26, 2011 11:13:20



// mysql server details

define('host', 'localhost'); // Your database host

define('user', 'root'); // Your database username

define('pass', 'test'); // Your database password

define('mydbdata', 'my'); // Your database name my

define('mydbacc', 'account'); // Your database name account

define('serveraddress', 'hamanchi ip'); // Your Server address

define('serverport', '5816'); // Your serverport

define('mydb', 'my'); // Your my database

define('servername', 'BlackThunder Online'); // Your Server Name

define('poweredby', 'Powered By *****************'); // Dont Delete!

define('imgdir', 'http://hamanchi ip/'); // Your Image dir



// conect to database

@mysql_connect($myhost, $myuser, $mypass) or die('<h1>Unable to connect to database server.</h1>');

@mysql_select_db(@mydb) or die('<h1>Unable to connect to database server.</h1>');



?>
I automaticlly noticed and i didnt say it a bit ago, This line,
Quote:
define('serverport', '3306'); // Your serverport
is the wrong port. 3306 is the mysql port.
This is the correct port for the server not mysql.
Quote:
define('serverport', '5816'); // Your serverport
And, I think this line(s) here
Quote:
@mysql_connect(host, user, pass) or die('<h1>Unable to connect to database server.</h1>');

@mysql_select_db(mydbdata) or die('<h1>Unable to connect to database server.</h1>');
Should be
Quote:
@mysql_connect($myhost, $myuser, $mypass) or die('<h1>Unable to connect to database server.</h1>');

@mysql_select_db(@mydb) or die('<h1>Unable to connect to database server.</h1>');
But try my config (ive edited it so it would be easier for you)and just edit the hamanchi IP spot and try it.
This is pretty much the config that i use, and it does work so i thought maybe that would help.
If it doesnt, Sorry, I tried to help.
And King_Arthur
The site files, by looking at the config, is from the EO section. Just saying.
08/31/2011 16:17 San-Goku#12
no nothing happens...

look:
[Only registered and activated users can see links. Click Here To Register...]

register.php:
Quote:
<?php
include('config.php');
?>
<script type="text/javascript" src="./inc/md5.js"></script>
<form method='post' action='register.php?act=register'>
<b><strong><font color=white>Please make sure you remember your Account ID and Password</font></strong></b><hr>
<tr><td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td width="64" valign="top"></td>
<td valign="top">
<table width="100%" border="0" cellspacing="10" cellpadding="0">
<tr><td><strong><font color=white>Account ID:</font></strong></td>
<td width="66%"><input type="text" size="30" maxlength="15" name="id" id="id" title="* Only 4-15 Words/number"></td></tr>
<tr><td><strong><font color=white>Password:</font></strong></td>
<td><input class=it id="ipassword" type="password" size="30" maxlength="15" name=pass title="* Only 4-15 Words/number"></td></tr>
<tr><td><strong><font color=white>Retype Password:</font></strong></td>
<td><input class=it1 id="ipassword" type="password" size="30" maxlength="15" name=retpass title="* Only 4-15 Words/number"></td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<br /><br />
<TABLE align="center">
<tr><td align="center"><input type="hidden" name="hash"><input class=Butt type=submit onclick="hash.value = login(pass.value)" value='register' name=B1></td></tr>
</table>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
if($_GET['act'] == "register")
{
mysql_select_db($mydbacc);
$userid = trim($_POST['id']);
$password=trim($_POST['pass']);
$passretype=trim($_POST['retpass']);
$hash=$_POST['hash'];
$_SERVER['REMOTE_ADDR'];
if($userid=="" || $password=="" || $passretype=="" )
{
echo "<center><font color=white>You must fill all information in the Required Field!</font></center>";
}
else
{
if($password == $passretype)
{
if(!ereg("^[0-9a-z]{4,15}$",$userid))
{
echo "<center><font color=white>Only letters and numbers only are allowed.Long 4 to 15 words</font></center>";
}
else
{
$res = mysql_query("select * from account where name = '".$userid."' order by id desc");
if(mysql_num_rows($res) == 0)
{
mysql_query("insert into account (name,Password,Reg_date,netbar_ip) values ('".$userid."','".$hash."','".date("y-m-d H:i:s", time())."','".$_SERVER['REMOTE_ADDR']."')");
echo "<center><font color=white>Account successfully registered!</font></center>";
}
else
{
echo "<center><font color=white>This account has been registered, please select another!</font></center>";
}
}
}
else
{
echo "<center><font color=white>Password authentication is not the same as your Password</font></center>";
}
}
}
?>


<body background=http://localhost/black/img/bg.png>
config.php:
Quote:
<?php
require_once './inc/class.captcha.php';
// Configurations
$myhost="localhost";
$mypass="test"; //your server login password
$myuser="root"; //your server login username
$mydbacc="account"; //your server account database
$mydbdata="my"; //your server my database name
$serveraddress="5.66.**,***"; //your server ip
$serverport=3306; //your server connection port
$mydb="my"; //your server my database
$servername = "BlackThunder Online"; //Put your servername here.
$link = "http://5.66.**.***"; //Put your website link here

// Dont Edit after this
mysql_connect($myhost,$myuser,$mypass);
mysql_select_db($mydb);
?>
08/31/2011 16:23 xTwiztedKidx#13
as i stated above. 3306 CANNOT be used. Its the MySQL Port. Change it to 5816 [Which is the Server Port] and try again.

this below is the config u just gave us, the red is the error or stuff u forgot to add.
Quote:
<?php
require_once './inc/class.captcha.php';
// Configurations
$myhost="localhost";
$mypass="test"; //your server login password
$myuser="root"; //your server login username
$mydbacc="account"; //your server account database
$mydbdata="my"; //your server my database name
$serveraddress="5.66.**,***"; //your server ip
$serverport="5816"; //your server connection port the " are needed also.
$mydb="my"; //your server my database
$servername = "BlackThunder Online"; //Put your servername here.
$link = "http://5.66.**.***"; //Put your website link here

// Dont Edit after this
mysql_connect($myhost,$myuser,$mypass);
mysql_select_db($mydb);
?>
08/31/2011 16:45 King_Arthur#14
San-Goku: You now have a different config.php than before. Which one is the real one?
Also, instead of using 'localhost' just use '127.0.0.1' and see if that helps if you aren't mix-matching different php files.

xTwiztedKidx:
PHP Code:
define('host''localhost'); // Your database host

define('user''root'); // Your database username

define('pass''test'); // Your database password

@mysql_connect($myhost$myuser$mypass) or die('<h1>Unable to connect to database server.</h1>'); 
host != $myhost

EDIT: Any problems with the server port should be inconsequential at the moment anyway since you can't even see the site yet. You can wait to fix those as your script is failing to connect to mysql.
08/31/2011 16:48 xTwiztedKidx#15
Yes, King_Arthur I do agree, Its even different from the one I suggested. I also noticed he is using Port 3306 which is MySql, And you need to use 5816. Which is the server port. And he don't have the quotations around the port number which will also throw an error.

The reason the site is failing to connect can be because of the Port. But, I could be wrong. It can also be other reasons beyond that.

EDIT: Nevermind I believe you are right on the port thing King_Arthur. Sorry for the confusion. Try the localhost trick that King_Arthur stated above.