Error connecting to database. [SQL]
#1

Hi,
I have been using a UCP for SA:MP which involves a news.php and several other files which require a mySQL database details to be entered. These files worked before with the exact same host I am using now, I have been in touch with the host and they said that everything is fine on their end and they confirmed that the details I was entering are correct. The following is just one of the files that is causing a problem(any file which involves connecting to database has the exact same error message apart from the location and file name of course)

Error:
Код:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'X' (4) in /home/XXXXX/public_html/samp/news.php on line 2
Error connecting to database!
File:
Код:
<?php
$con = mysql_connect("X","XX","XXX");
if(!$con) die("Error connecting to database!");
$con = mysql_select_db("XXXX");
if(!$con) die("Error selecting database!");
$string = "SELECT * FROM `news` ORDER BY `ID` DESC";
$result = mysql_query($string); 
if(!$result)
{
	echo "Error reading news from MYSQL!";
	exit;
}
echo '<center><table width="80%"><tr><td>';
while($news = mysql_fetch_array($result,MYSQL_ASSOC))
{ 
   echo '<center><br><br><br><span style="color:white"><strong><font size="5">'.$news['Title'].'</font></strong><br><br>'.$news['Text'].'</span></center><span style="color:white"><br><p align="right"><i>by '.$news['Admin'].' at '.$news['Time'].'</i></p></span><br>'; 
} 
	echo "</td></tr></table></center>";
?>
Note: XXX = Information which I have hidden.
Note: The problem is definetely in the file as I tried the same file on a different SQL database on a different host, same problem
Note: The SA:MP server can connect to the SQL database just fine, this web server files is the only issue.
Reply
#2

IS that server in localhost or what?
Reply
#3

Hosted by Vortex Servers.
Reply
#4

is on the same machine as php server?
Reply
#5

Quote:
Originally Posted by iJumbo
Посмотреть сообщение
is on the same machine as php server?
No, I don't think so. I bought two seperate services - Web Hosting and Gameserver. I had done this before aswell on Vortex Servers.
Reply
#6

so maybe ask for your mysql provider if allows mysql on external connections
Reply
#7

Quote:
Originally Posted by iJumbo
Посмотреть сообщение
so maybe ask for your mysql provider if allows mysql on external connections
They said that everything on their end is fine, I explained to them what I wanted to do and they said that their systems are fine, it is the script that is not allowing it.
Reply
#8

Turns out they don't allow it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)