Questions tagged [mysql-connect]

The `mysql_connect` function opens a connection to a MySQL server.

The mysql_connect function opens a connection to a MySQL server. However, this function, along with all other mysql_* functions, are deprecated in PHP 5.5.0 and should be avoided (see the red box). Consider using prepared statements with either PDO or MySQLi instead.

192 questions
0
votes
1 answer

mysql_connect warning, database host issue

I suddenly gοt this: Warning: mysql_connect(): in C:\xampp\htdocs\login.php on line 12 cannot connect to server A connection attempt failed because the connected party did not properly respond after a period of time, or established connection…
St.Ios
  • 5
  • 1
  • 3
0
votes
2 answers

mysql connection closes after a certain time? (PHP)

I have a script that takes several minutes to execute. The mysql connection is established at the beginning (mysql_connect), then a loop with some queries follows (mysql_query). That loop lasts very long, and after a few minutes the script throws a…
Alex
  • 12,205
  • 7
  • 42
  • 52
0
votes
2 answers

mysql connect - Moving my website to a local host

I've created a website using a CMS. I've been making updates to the live site and, finally after months of "tsk tsk" from my dev friends have decided to create a local version on my computer to test updates on before making live. I copied all of…
Doug Fir
  • 19,971
  • 47
  • 169
  • 299
0
votes
1 answer

Access denied for user 'myUser'@'localhost' (using password: YES)

Does that (using password: YES) means password is not matching ? I am getting this error even I , as root user, has granted privileges to all the databases to the user ! GRANT ALL PRIVILEGES ON *.* TO 'prashant'@'localhost' IDENTIFIED BY PASSWORD…
Prashant Singh
  • 3,725
  • 12
  • 62
  • 106
0
votes
3 answers

Can't connect to mySQL server using PDO

I'm new to mySQL, and the code I used, which was working, is apparently out of date, so I switched to PDO. I tried to transfer my coding as accurately as possible from the old style to PDO, but now I can't connect and I'm sure I'm just doing…
Brian
  • 2,687
  • 9
  • 37
  • 39
0
votes
1 answer

HowTo: Connect to MySQL from PHP Using Different Files

Ok so I did a search to see if there other posts that explain this completely... Well i'm here now :) SCENARIO: I want to connect to your mysql database via html. I DO NOT want to set the parameters explicitly everytime I wish to perform a query I…
Craig Wayne
  • 4,499
  • 4
  • 35
  • 50
0
votes
1 answer

php mysql mysql_connect and closed connections

Possible Duplicate: Is closing the mysql connection important? Edit - the above is not the same question and does not answer my question here. Here I speak specifically about the case that you DONT issue a query on the opened connection and I…
iss42
  • 2,720
  • 3
  • 21
  • 37
0
votes
2 answers

mysql_close is not working

i want to close an opened connection using mysql_close() but when i go at my server and check the amoutn od opened connections in my server the connections are increased! for example i have 100 opened connections in my mysql data base and i have a…
0
votes
4 answers

can't seem to connect to msql, local host?

i can't seem to run this code under local host, my goal is to make a table that is supposed to show in a website but when i try to connect i get the error: Warning: mysql_connect(): in C:\xampp\htdocs\PhpProject2\hent.php on line 5 can not…
Madde
  • 471
  • 1
  • 7
  • 22
0
votes
2 answers

MySQL connection within a PHP function overwrites existing connection (other database) - how can I prevent this?

We open a MySQL connection to host_1 at the beginning of our script. Somewhere in between, we call a function that opens & closes a connection to host_2 (function retrieve_information_from_host_2). Unfortunately, the code after the function call…
Lionel
  • 1,949
  • 3
  • 17
  • 27
0
votes
1 answer

mysql_connect to PDO connection

I've been trying to convert a mysql_connect connection into a PDO connection with no success, here is what I have: $host = 'localhost'; $user = 'root'; $pwd = ''; $db = 'jdlferreira'; $connection =…
Jorg Ancrath
  • 1,447
  • 10
  • 34
  • 61
0
votes
0 answers

mysql_connect and mysql_select_db can't be separated in code?

I'm not sure what the problem is, I have a file called dbs.inc.php which contains the user/pass/database variables and mysql_connect(); statement. If I include("dbs.inc.php"); in a function the next line underneath it always has to be…
Binxalot
  • 41
  • 7
0
votes
1 answer

Multiple database connection not working with new_link=TRUE and sql.safe_mode = OFF

I'm tryng to connect a different database from a php function (assuming there's a current connection to another database). I'm using mysql_connect() with new_link parameter set to TRUE as you can see below. How is it possible the following code…
Stephane
  • 4,978
  • 9
  • 51
  • 86
0
votes
3 answers

mysql_connect always allows access

I am attempting to connect to a mySQL database running on my local computer using a local test server set up using XAMPP. I am just using the root account which has no password assigned. I tried it as below and everything appears to work fine. I got…
0
votes
3 answers

MySQL database SSL connection using PHP

I have a database setup non remote server. What im trying to do is establish the connection using PHP. All the settings on the server are OK as I tested it using MySQL workbench using following details: Hostname : xxx.xx.xx.xxx Port - blank so as…
Dom
  • 3,126
  • 14
  • 46
  • 68