This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Cant connect to mysql wtf?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4ever16
Veteran Member
Join Date: Apr 2015
Old 07-06-2017 , 04:02   Cant connect to mysql wtf?
Reply With Quote #1

Hello i dont understand i just cant connect to my own mysql.
Im running a plugin which conencts to mysql.
But every time it says cant connect to mysql.

What i have done.
Added remote accces so that mysql server can accept acces from the server.
Added all right information.

#define MIX_HOST "mysql adress"
#define MIX_USER "database username"
#define MIX_PASSWORD "password"
#define MIX_DATABASE "database name"


I have tryied to test mysql connection. This code which uses mysqli works.

PHP Code:
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname 'X';
$dbuser 'X';
$dbpass 'X';
$dbhost 'X';
$link mysqli_connect($dbhost$dbuser$dbpass) or die("Unable to Connect to '$dbhost'");
mysqli_select_db($link$dbname) or die("Could not open the db '$dbname'");
$test_query "SHOW TABLES FROM $dbname";
$result mysqli_query($link$test_query);
$tblCnt 0;
while(
$tbl mysqli_fetch_array($result)) {
  
$tblCnt++;
  
#echo $tbl[0]."<br />\n";
}
if (!
$tblCnt) {
  echo 
"There are no tables<br />\n";
} else {
  echo 
"There are $tblCnt tables<br />\n";
}
?>
This code to test with mysql code doesnt work.

PHP Code:
<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname 'name';
$dbuser 'user';
$dbpass 'pass';
$dbhost 'host';
$connect mysql_connect($dbhost$dbuser$dbpass) or die("Unable to Connect to '$dbhost'");
mysql_select_db($dbname) or die("Could not open the db '$dbname'");
$test_query "SHOW TABLES FROM $dbname";
$result mysql_query($test_query);
$tblCnt 0;
while(
$tbl mysql_fetch_array($result)) {
  
$tblCnt++;
  
#echo $tbl[0]."<br />\n";
}
if (!
$tblCnt) {
  echo 
"There are no tables<br />\n";
} else {
  echo 
"There are $tblCnt tables<br />\n";
}
?>
The PHP version of my database/php my admin is 5.6.30.

So what do you think the problem is why cant amxx plugins connect to the mysql?
Do i need changes in the plugin code so that it uses msqli instead of msql?
4ever16 is offline
Rohanlogs
Senior Member
Join Date: Nov 2015
Old 07-06-2017 , 09:37   Re: Cant connect to mysql wtf?
Reply With Quote #2

Hi. Your amxx plugin can't connect to the database?
Can you provide source code of that plugin?
It's also better to use constants rather than defines.
__________________
Rohanlogs is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 07-06-2017 , 10:25   Re: Cant connect to mysql wtf?
Reply With Quote #3

Found out that my host didnt allow remote acces but it sed clearly in cpanel that its allowed.
4ever16 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode