Screenshot
Connection timed out when tried to fetch emails from the cpanel roundcube.
All credentials are perfect and hostname and server also working fine.
$hostname = '{mail.server.com:993/novalidate-cert/imap/ssl}';
$username = 'username';
$password = 'password';
$stream = imap_open($hostname, $username, $password) or die('Cannot connect: ' . imap_last_error());
print_r(imap_errors());
Can anyone help please?
Thank you
Related
I`m working on a java swing app. so that i have created a database called c_app in MySQL server workbench. what i need is to fetch data into a HTML page using PHP.
$username = "root";
$password = "";
$hostname = "localhost:3307";
$db = "c_app";
//connection to the database
$dbhandle = mysqli_connect($hostname, $username, $password, $db)
or die("Unable to connect to MySQL");
This code segment gives me Warning: mysqli_connect(): (HY000/1049): Unknown database 'c_app' in C:\xampp\htdocs\C_AppWeb\linkpage.php on line 7
Unable to connect to MySQL
What is the problem here? do i need phpmyadmin database rather than MySQl database? can anyone help me?
First one, both phpmyadmin and workbench are not database. They are tools to work with database.
I see you use port 3307 in your code, so let you try:
$username = "root";
$password = "";
$hostname = "localhost";
$port = 3307;
$db = "c_app";
//connection to the database
$dbhandle = mysqli_connect($hostname, $username, $password, $db, $port)
or die("Unable to connect to MySQL");
I am trying to access to office365 inbox, but I am getting this message
PHP Warning: imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl}
Here is my code
$hostname = '{outlook.office365.com:993/imap/ssl/novalidate-cert}';
$username = '*****';
$password = '*****';
$fp = fopen('cox_cash [30 40].txt', 'w+');
if (!$fp) die("Impossible d'ouvrir le fichier");
/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to : ' . imap_last_error());
For me, the issue was not having the imap library for php. Try using function_exists('imap_open') to check if you actually have the library. function_exists() returns true if your php has the function, false otherwise. Simple if statement with echos should do the trick.
I am getting this message in my site all of a sudden without making any changes in the config file. I will post my config code to see if there are any issues with it.
define('DB_SERVER', 'www.victorexoticagoa.com');
define('DB_SERVER_USERNAME', '******');
define('DB_SERVER_PASSWORD', '********');
define('DB_DATABASE', 'victor');
define('USE_PCONNECT', 'false');
define('STORE_SESSIONS', 'mysql');
define('CFG_TIME_ZONE', 'Asia/Kolkata');
The above code is from the configure.php file.
The below code is the connection:
tep_db_connect() or die('Unable to connect to database server!');
And the code below is the function which does the connection:
function tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link') {
global $$link;
if (USE_PCONNECT == 'true') {
$server = 'p:' . $server;
}
$link = mysqli_connect($server, $username, $password, $database);
if ( !mysqli_connect_errno() ) {
mysqli_set_charset($$link, 'utf8');
}
return $$link;
}
Any help will be gladly appreciated. Thanks
Check if your database is up by using the following command in a command shell:
mysql --host=www.victorexoticagoa.com --port=yourport --user=youruser --pass=yourpass
If it cannot connect, the problem is the server, not your code.
Have you checked if that is the way you need to connect or the port to connect? I dont see the port (thats not supposed to be port 80 most times). Please check docs of the host and ask for details. It should be documented.
To fetch gmail mails, i am using below code. it is working fine in local, but i am getting error in server like :
Warning: imap_open(): Couldn't open stream {imap.googlemail.com:993/imap/ssl/novalidate-cert}INBOX in C:\xampp\htdocs\criticaloglive\email_real.php on line 10
Cannot connect to Gmail: Too many login failures
Here's my code :
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$server = '{imap.googlemail.com:993/imap/ssl/novalidate-cert}INBOX';
$username = 'mymail#gmail.com';
$password = 'mypassword';
// try to connect
$inbox = imap_open($server,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
Use the $hostname instead of $server. also try with not secure imap with port 143
$inbox = imap_open($hostname,$username,$password) ;
this code works for me.
I have a ton of experience connecting to MySQL, but I'm attempting to connect to a SQL Server for the first time.
I've been given an IP address, server name, and a port. I've tried every combination I can think of for the server string to make the connection, but nothing appears to be working:
"127.0.0.1:1443\servername"
"127.0.0.1,1443\servername"
"servername\127.0.0.1:1443"
"servername\127.0.0.1,1443"
etc...
All fail.
I guess I'm asking for the correct formatting of the server parameter string to connect to MS SQL from a php script.
$ip = '127.0.0.1';
$port = '1433';
$server_name = 'servername';
$server = "$ip,$port\servername"; // <-- this is the line I need help with
$username = 'user';
$password = 'pass';
$con = mssql_connect($server, $username, $password)
or die('Could not connect to the server!');
Thanks in advance!
if you are using linux
$con = mssql_connect($server_name.":".$port,$username,$password);
or on windows
$con = mssql_connect($server_name.",".$port,$username,$password);
to connect mssql server
$ip = '127.0.0.1';
$port = '1433';
$server_name = 'servername';
$server = "$ip.":".$port";
$username = 'user';
$password = 'pass';
$con = mssql_connect($server, $username, $password)
or die('Could not connect to the server!');
This should work