mysql-connect

What is the best way to keep your MySQL credentials private in PHP?

不羁岁月 提交于 2019-12-02 12:13:02
问题 When it comes to programming your web application in php, what is the most efficient way to prevent your MySQL information from being disclosed or discovered by another person (third party)? The information would include domain names and log in and passwords used in the connet functions. For an example a good procedure might be keeping your mysql connection functions in a separate php file, etc. Any ideas? 回答1: Keep your credentials in a separate .php file outside the document root (so it is

Why do we have to close the MySQL database after a query command?

最后都变了- 提交于 2019-12-01 07:03:30
I'm starter. I want to know what will happen if we don't close the MySQL connection. 1- Is it possible to open more than one database if we don't close them? I mean can we open more than one database in a same time? 2- Does closing database increase the speed? 3- Is it necessary to close the database or it is optional? Look at this code. I don't use "mysql_close()" so I don't close the database after each request. There are a lot of requests for this PHP page. Maybe 50000 per each minute. I want to know closing database is necessary for this code or no? <?php //Include the file that lets us to

Why do we have to close the MySQL database after a query command?

谁说胖子不能爱 提交于 2019-12-01 04:26:33
问题 I'm starter. I want to know what will happen if we don't close the MySQL connection. 1- Is it possible to open more than one database if we don't close them? I mean can we open more than one database in a same time? 2- Does closing database increase the speed? 3- Is it necessary to close the database or it is optional? Look at this code. I don't use "mysql_close()" so I don't close the database after each request. There are a lot of requests for this PHP page. Maybe 50000 per each minute. I

mysql_pconnect(): send of 5 bytes failed with errno=32 Broken pipe

一笑奈何 提交于 2019-11-29 20:51:32
问题 I've been using the same DB abstraction library for years. But today it started writing these Notice (8) messages in my log. The application is working correctly but every time a script connects to the DB the same notice is logged. I cannot think what might have changed. This is happening on my local dev machine. OS X 10.6.2 PHP 5.3.0 (cli) mysql Ver 14.12 Distrib 5.0.87 mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $ 回答1: If someone is struggling with this issue, here is the fix: Try

Wierd and Annoying error: Call to undefined function mysql_query() [duplicate]

China☆狼群 提交于 2019-11-28 13:44:53
This question already has an answer here: Why shouldn't I use mysql_* functions in PHP? 15 answers I've been at this for more than an hour now, I can connect to my database and all (doesn't give any errors) but i get the following error when i try to use "mysql_query($query);" Call to undefined function mysql_query() I've already tried enabling: extension=php_mysql.dll extension=php_mysqli.dll and I've added: extension_dir = "ext" extension=php_mysql.dll at the end of the import list. Between every change I made I restarted all processes in exampp and after every single solution that I

PHP: mysql_connect not returning FALSE

ぃ、小莉子 提交于 2019-11-28 09:40:17
问题 I have a form where the user enters their database information and can click a link that uses AJAX to send the credentials to this page. The problem I have is that as long as they enter the correct host name the script returns TRUE . Is there another way to test this so that it will return FALSE if the username and password are not valid? $h = urldecode($_GET['h']); $u = urldecode($_GET['u']); $p = urldecode($_GET['p']); $con = mysql_connect($h, $u, $p); if(!$con){ echo 'Could not connect'; }

Wierd and Annoying error: Call to undefined function mysql_query() [duplicate]

孤人 提交于 2019-11-27 07:51:12
问题 This question already has an answer here: Why shouldn't I use mysql_* functions in PHP? 15 answers I've been at this for more than an hour now, I can connect to my database and all (doesn't give any errors) but i get the following error when i try to use "mysql_query($query);" Call to undefined function mysql_query() I've already tried enabling: extension=php_mysql.dll extension=php_mysqli.dll and I've added: extension_dir = "ext" extension=php_mysql.dll at the end of the import list. Between

mysql_connect VS mysql_pconnect [closed]

感情迁移 提交于 2019-11-26 16:02:14
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have this doubt, I've searched the web and the answers seem to be diversified. Is it better to use mysql_pconnect over mysql_connect when connecting to a database via PHP? I read that pconnect scales much better, but on the other hand, being a persistent connection... having 10 000 connections at the same time

mysql_connect (localhost / 127.0.0.1) slow on Windows platform

蹲街弑〆低调 提交于 2019-11-26 15:59:48
问题 I am using Windows 7, Apache 2, PHP 5, MySQL 5, all are on the same machine. I have found an interesting issue, I have the following code: $sql = "select * from user1"; $conn = mysql_connect("localhost", "root", "xxxxxxxx"); mysql_select_db("test1"); mysql_query("set names utf8"); $result = mysql_query($sql, $conn); while ($row = mysql_fetch_assoc($result)){ foreach ($row as $key => $value){ echo $key." => ".$value." || "; } echo "<br/>"; } mysql_free_result($result); mysql_close($conn); The

Connecting to remote MySQL server using PHP

谁说我不能喝 提交于 2019-11-26 04:25:48
问题 I am attempting to connect to a remote MySQL server from my local machine virtualhost using the following code: $conn = mysql_connect(\"$dbhost\", \"$dbuser\", \"$dbpass\") or die(mysql_error()); mysql_select_db($dbname, $conn) or die(mysql_error()); My problem is that I am unable to connect locally, receiving the error: Can\'t connect to MySQL server on \'xxx.xxx.xxx.xxx\' (10060) This is not the case when I upload the same PHP file to the server. I am able to query the database with no