Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Bug 23891 MySQL Runs Out Of Connections


http://bugs.php.net/bug.php?id=23891

According to this report, what the person was asking isn't a bug, it's
a feature (rimshot).

I'm running into this problem almost exactly, and really don't
understand what the answer is. The support person snidely suggests
reading the manual, which is always great advice, but in this case
really doesn't help out.

Could someone explain what "If you use mysql_select_db() or slightly
different connection string you can have more open connections then
you have process." means?

If I don't use mysql_select_db, then what do I use?




View Complete Forum Thread with Replies

Related Forum Messages:
MySql Is Loaded When Runs From Command Line, But Not Through IIS
Sorry for the newbie question, but I've been searching and searching and
haven't found an answer to this one yet.

I installed PHP and MySql (both latest versions) yesterday on a machine
running Windows 2003 Server with IIS6. Code:

View Replies !
How Do I Create A Link That Runs A MySql Query When Pressed!!
I Want To Create A Link, And When You Press That Link It Runs A MySql Query.

View Replies !
Query Runs In Mysql But Returns Error 1064
The same query runs in mysql and in Zend interface but not runs when using inside php script. I am receiving the error:

"1064 - You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'str_qry_Insert' at line 1"

INSERT INTO fnd_script_type (type_name) VALUES ('test1')

I already have tried it with as:

INSERT INTO `fnd_script_type` (`type_name`) VALUES (`test1`)
INSERT INTO fnd_script_type (`type_name`) VALUES (`test1`)
INSERT INTO fnd_script_type (type_name) VALUES (`test1`)

what am i doing wrong ?

View Replies !
Too Many MySQL Connections!
I had the "Too many MySQL connections" error on a page that is password protected to 150 users, and it uses one simple table and a simple SELECT * FROM table. The site wasn't launched or noticed, so all 150 users can't hit it at the same time. What can cause this upsetting error?

View Replies !
Two Mysql Connections
Not really tried going two ways at once, but I have an include_once
connection to a mysql_database, now I need to retrieve info from a second
mysql_database ..

My mysql_connects are getting confused. So, (I've had a couple of beers), am
I opening up too many at once?

I'll look again in the morning, but am thinking that it is a bad idea to
leave two connections open all the time ...

View Replies !
2 MySQL Connections
There's a database which stores various applications and a separate database (different connection) that stores forum information. These are tied together through a userid column. I need to have a forum rank posted along with the application list, and was wondering if it's possible to have 2 active connections.

Essentially, while the rows are fetched from the database, it can pull one bit of info from the other. Is this possible or do I need to recode and merge the databases?

View Replies !
Mysql Connections
I am all for saving on connections but I dont really understand their reasonings and procedure.

When I code, I place one db connect at the top of the page and then I do my queries. But in their connection they first check to see if the connection already exists. Isnt this redundant when using mysql_connect? Since the connection closes at the end of the script, shouldnt that mean that there will never be an available connection when you go to a page? or should I be adding this sort of connection checking in to my scripts?

View Replies !
Mysql Connections With Authentication
Maybe this is a foolish request but I am a newbie to all of this.
I have a private members site with all pages protected using the below script and it works very well.
I also have a quick and dirty (dreamweaver coded) page that displays my online music,both need a connection to a mysql database, same database but different tables.
My problem is and no doubt the experts here will already have guessed both codes will not exist on same page, is there a way around this?, if so please help me. and yes my code maybe messy but I am trying to learn. I have included samples below.

$connection = mysql_connect($this->HOST, $this->USERNAME, $this->PASSWORD);


Script to protect member pages

<?
if (!class_exists (auth))
{
include ("../auth.php");
}
include ("../authconfig.php");
include ("../check.php");

if ($check["level"] != 6)

{
header('Location: ../no_access.php');
exit();
}
?>


Connection for Music page

$music = mysql_pconnect($hostname_music, $username_music, $password_music) or die(mysql_error());


Music page opening script

<?php require_once('../Connections/music.php'); ?>
<?php
$currentPage = $HTTP_SERVER_VARS["PHP_SELF"];

$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($HTTP_GET_VARS['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $HTTP_GET_VARS['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_music, $music);
$query_Recordset1 = "SELECT title, artist, link, server FROM music ORDER BY title ASC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $music) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($HTTP_GET_VARS['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $HTTP_GET_VARS['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

$queryString_Recordset1 = "";
if (!empty($HTTP_SERVER_VARS['QUERY_STRING'])) {
$params = explode("&", $HTTP_SERVER_VARS['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . implode("&", $newParams);
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>

View Replies !
Multiple Mysql Connections To The Same Db?
I know from reading on php.net that there is a boolean value you can set in mysql_connect() so that it will create a new link each time, even with the same arguments. But how do you specify which connection to use in your mysql_query (s)?
PHP Code:

View Replies !
MySQL Persistant Connections
I have a problem with MySQL connections on my server. There are only about 10 different databases that are regularly accessed, using PHP scripts. This is done using mysql_pconnect, so the connections should be persistent. From what I learned, this would mean that if another connection is necessary for the same database/user combination, an old, already existing connection can be used without the need for establishing a new one. This sounds good to me, because I have only few databases that are often accessed, so this way there are only few connections open. Recently, however, I had a major problem when there were too many connections. There were more than the maximum, so no more connections were allowed. When I showed the processes, I saw that there were a lot of the same connections (same user accessing the same database). I do now understand why. If I use persistant connections, there is no need to create all these duplicate connections, right?

I now kill off manually the connections every now and then so that there are not too many, but that's not a long term solution. I hope somebody knows how to limit the number of connections automatically.

View Replies !
Running Out Of Mysql-connections
I'm having a flash-file (swf) which is requesting info from a PHP-file every
ten seconds. The PHP-file connects to a mysql-database, make a short query,
and then close the connection, before it returns the info to the swf.

Like this:
$mysqli = mysqli_connect($dbhost, $dbusername, $dbuserpassword,
$default_dbname, $port); //open connection
$number = getNumber(); //the function makes a query, and return a number
mysqli_close($mysqli); // closing connection
echo "&number=$number"; // returns the number to yhe swf

The problem is that it seems like the mysqli-connection will not close from
time to time. I have a limitation of 1000 connections, which should be
enough really. But if I run the flash-file for hours (say 8 hours), the
limitation of 1000 OPEN connection is reached, even if I was hoping there
should only be ONE open connection at a time.

View Replies !
Mysql Sleeping Connections
We're experiencing a problem with sleeping connections on one of our servers. We're not using persistant connections and every page ends with mysql_close(); So I cant imagine what is causing them and googling just brings up pconnect as the cause (which we're not doing).

We dont have this problem on our other server, we get the occassional sleeper but I've never seen more than 2 active at the same time and never for very long.

View Replies !
Classes & MySQL Connections
In my script I use some include files with class definitions (class for db connection, auth class, session class and so on...). The code looks something like this: Code:

View Replies !
"Please Wait" Page While Php Runs Mysql Queries
Does anyone have any idea what I should google to create a "splash page" that tells the user to wait while a few mysql quieries are run through the php page?  It takes anywhere from 5 to 20 seconds, and I don't need a progress meter, just a splash page so they do not go anywhere and the user doesn't think there is a problem with their browser or network connection.

View Replies !
Mysql_pconnect Make Mysql Too Many Connections
mysql_pconnect -> too many connections -> increase mysql max_connections -> take up more memory -> slower?!

there's many static file: html/images and dyn file: *.php
a php page is loaded, then images is requested, and then keep-alive idle, so most of mysql thread is idling...

what can i do to optimize?

View Replies !
Handling Multiple MySql Connections
I thought this was possible, but apparently I am wrong, or I am doing something wrong.
I need to be able to track and use two different mysql connections in a class. So far my class looks like this: PHP Code:

View Replies !
SLOW MYSQL Remote Connections
I was having a major issue connecting to a MySql Database from other machines on my network. localhost connections were just fine.

But I wanted to connect to the DB remotely through PHP and the response was terrible.

Connecting to Mysql Remotely using GUI's like MySql Front was terrible as well.

I am hosting the MySql DB on a Windows XP Service Pack 2 machine, loaded to the teeth with processing and memory. But the result were terrible. Code:

View Replies !
How To Handle 2 Mysql Database Connections
Okay, I know this has to be simple, but i've been searching it for a while now, I need to have two database connections open, database one will be to get information to query the second database.

I am not sure how to set this up, I know how to get one database connected, but to get two databases on two different servers is a little above me and i'd love to know how to work it, I've been searching a while, and if you know of a website that has it, could you post it for me? Thank you

View Replies !
Apache+mySQL Leaving Connections Open?
I've recently started getting 'too many connections' from our website
and I don't really know why.

Nearly every page of our website includes a file which does a single
pconnect which all my scripts share. At this point I would expect a
single connection per httpd child running which is closed when the child
is destroyed. mysql max_connections is currently 100 and httpd max
clients is 100 so I shouldn't get this problem should I?

As a shorter term fix, can anyone tell me the syntax to increase
max_connections from my.cnf. The manual on the website is not very clear?

View Replies !
Scope Of Mysql Connections With Multiple Php Snippets
if i have a simple question- if i open a database connection in one
snippet of php, can i use it in a subsequent snippet in the same php
file:

<html>
<head>
</head>
<body>
....
<?php

//open database here
?>
//more html
<?php
//now use open database
?>

View Replies !
Sessions And Persistent Connections To MySQL Database
PHP/MySQL and I've heard about maintaining a
persistent connection to the database. To save overhead, I'd like to
maintain the connection in a session variable, but I have a few
questions first.

I'm able to establish session variables and test them with isset() to
avoid re-defining them with each new web-page load. So is this really
as simple as

if (!isset($_SESSION['connection'])) {
$connection = mysql_connect("SomeServer","UserName","password");
$_SESSION['connection'] = $connection;
};

Will this work? and is there a better way to do it--or a more
conventional way? What should I be thinking about vis a vis security
regarding this connection.

Is there a recommended way to make the session's connection variable
"expire"? I suppose I could store the time the connection was
established and then check the elapsed time with each web-page
re-load, dumping the session if it's been too long.

Is there a preferred way to store $connection without using
$_SESSION[]?

View Replies !
Limits On Mysql Connections And Mysql_close Is Not A Soultion?
Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. See also freeing resources.

Freeing resources
Due to the reference-counting system introduced with PHP 4's Zend Engine, it is automatically detected when a resource is no longer referred to (just like Java). When this is the case, all resources that were in use for this resource are made free by the garbage collector. For this reason, it is rarely ever necessary to free the memory manually by using some free_result function. Code:

View Replies !
HTTP Flooders Causing Mysql To Open Too Many Connections
Currently I am connecting to mysql on every page within my site, as they all require information from a db. People are using HTTP flooders that request the homepage (GET /index.php)

25times per second that is causing mysql to open too many connections, which is causing my host to suspend mysql usage. Does anyone know of any protection,or way around this?

View Replies !
Standard Mysql Queries - Warning: Mysql_select_db(): Too Many Connections
This is what appears on my site when there:

Warning: mysql_connect(): Too many connections in /home/public_html/ca/sjsu/includes/settings.inc.php(2) : eval()'d code on line 12

Warning: mysql_select_db(): Too many connections in/home/public_html/ca/sjsu/includes/settings.inc.php(2) : eval()'d code on line 16

Warning: mysql_select_db(): A link to the server could not be established in /home/public_html/ca/sjsu/includes/settings.inc.php(2) : eval()'d code on line 16

What's going on?

View Replies !
Mysql_connect Vs. Mysql_pconnect In Mysql Connections Limits Issue
According to the manual, mysql_pconnect may exceed the number of connections allowed by MySQL. so I am using mysql_connect instead of mysql_pconnect.

The php manual said that "Note: The link to the server will be closed as soon as the execution of the script ends" Code:

View Replies !
Performance Issues With Frequently Closing/opening Mysql Connections?
I have been faced a couple of times with the situation that I wanted to
write a script and was worried about a too frequent opening and closing
mysql connections.

To give some examples:

1)I am trying to develop a photoalbum (also posted a topic called "array /
mysql question"). Of course I can use some wonderful open source albums but
at the same time I want to get more familiar with all the ins and outs so my
idea is a list of filenames, where the database connection should be
opened, a statement like"select filenames from photos" , and, every filename
maybe with a thumbnail is a link to a second page and the whole is followed
by closing the connection. The second page could be something like opening
the database connection, a statement like "select description ( and other
fields) from photos where filename = $filename" , and closing the database
again. Let's say the visitor looks at the picture and its description,
clicks on a link to the first page with the thumbnails and agin the
connection is opened and closed to execute the first select statement, the
visitor chooses another picture etc. etc....

2)On the left column there is a menu item
"activiteiten". when there are special activities like a music performancein
the near future they are shown below that menu item. A select statement is
done where the first announcement date, and the last announcement date are
checked and the records where the current date is between those values are
selected (and shown in the menu bar of course). Again the connection is
opened and closed again immediately after the select statement. However,
this query is stored in "header.php" so on every page that is visited, the
connection is opened and closed. It would also be nice to make a link on the
"one-photo-page" to the previous and the next photo, which leads again to
the open-select-close "ritual".

I am not really a php guru (but not a newbie either) and unfortunately I
could not find many info on google about the performance issues that can be
involved when I decide to write such scripts. There were some vague
indications that it is better to open and close a connection frequently than
leave it open too long in order to execute more queries but I could not
really find good documentation about it.

I also thought to store the results of the query into a session variable but
I am not sure about the performance issues of sessions either.

View Replies !
User Runs PHP
I have an app that uses PDFLib to read some images off the file system (Red Hat linux) and puts them into a PDF. I have permissions set on the directory to be readable by the owner and the group, 'images'.

I made apache a member of the group 'images' but get a permission denied error when trying to read an image from the images directory. Is there some other user that owns the PHP app.

Env.
PHP 5.03
Red Hat ES4
Apache 2.02

View Replies !
PHP Only Runs From Command Line
I know very little about PHP, but I was just curious to know
why exactly would some PHP code run fine from the command line but not
from the browser?

I'm just curious. I was working with someone else's PHP code that
supposedly created MySQL tables in a database and for some reason it
just wouldn't create the tables at all (no specific error message).
Someone suggested I run from the command line and when I did, it
worked...

View Replies !
Cleaning Up After A Script Runs
how do you clear all varialbles and arrays after a script is run?

View Replies !
Bad Query Runs With No Error!
there must be some weird setting on the mysql database i am using for this latest project. the following query runs without throwing an error:

SELECT start_time, last_access_time, user_ip session_data FROM demo_sessions WHERE id='b31fd40c7e9135f2b52e4f17c23fc3c54da137b8'

notice there is no comma between user_ip and session_data

what's the story here? seems like a real security risk to me because my server won't log bad requests.

View Replies !
Why Script Runs Differently With CRON?
I am running a PHP Script that downloads my RSS News (and the accompanying Thumbnail images)from the Web. When I execute it from CMD line, no problem. The News and Images are downloaded, great!

When I begin to update via CRON, no images are downloaded/written to disk.--I don't have this problem when it's RUN from a shared hosting account, it's only on my home Linux Box.

View Replies !
EXEC() Runs Process In Background
Exec, shell_exec, system, popen functions all run the process in the
background.
how can i get it to run the process normally.
my code looks like this:
<?
exec("batch_file.bat");
?>

am i doing anything wrong?

View Replies !
Close Window After Script Runs
When a user clicks on a link in their email, I have a browser window that opens in the background and runs a script confirming their desire to be added to our email directory. I basically want this window to open, run and then close without the user having to deal with it.

Is there a way in PHP to close the window after the script finishes running in it? Or should I revert to JavaScript? I want the script to be mobile so I've sort of ruled out processing it server side. TIA.

View Replies !
How Often Does Garbage Collector Runs In Sessions?
Does anybody knows how often the session garbage collector checks for expired session to delete them? is it possible to modify this timeframe? is it possible to call this function manually?

I am storing my sessions in a mysql database and i am using a session expiration of 5 seconds (just for testing), but after the session is expired the session record in the db table still exists.

and it looks the sessions aren't expiring either because if you still have the session cookie you can keep up with the session. Code:

View Replies !
Email Form Which Runs From An Iframe
I have set up an email form which runs from an iframe. The only problem is that when the script redirects the user to the success or error pages, these pages open within the iframe. Is there a way to specify the target window as 'parent'? Someone said that this could not be done via the php script and would have to be done with javascript in the html form itself.

View Replies !
Optimizing Query That Runs Slowly On Linux
I was wondering if anyone has any insight into why the query I have posted below runs exceedingly slow on my Linux server. I am using Php with a MySQL database. On both my development computers the query runs briskly. They are however both Windows boxes, one running Windows XP and the other running Windows 2000 Professional. Here is the culprit.....

View Replies !
Counter - Increased By One Everytime The Loop Runs
i want to make a counter that i can echo. its going to be used in a while loop so i want it to be increased by one everytime the loop runs so each time it runs it would look like this:

counter=1
counter=2
counter=3
etc.

View Replies !
Php Script Auto Runs At Specific Time?
Is it possible to have a php script automatically execute at a certain time without having to visit the page or manually executing the code?
For example, execute test.php every hour?

View Replies !
Switch Statement That Runs Through Cases Numbered 1-100:
I have a switch statement that runs through cases numbered 1-100:

What is the most optimal way to run this switch?

switch($a){

case 1:

case 2:

...
}

View Replies !
Header Function Runs Before Update To Database Is Made
I have been having some problems with a part of my login script. This is the two lines of script I am having problems with:

mysql_query("UPDATE " . $userName. " SET login = '$loginIN' WHERE pass = '$password' AND course = '$courseID'");
header( 'url=http://www.somewebsite.com/logged_IN.htm' );

The problem is that when this php script is executed the second line executes before the first and an update to the database is not made. I also tried the script without the second line and the first works then.


View Replies !
Query Runs Multiple Times Under Heavy Server Load.
I have been having an issue with some MYSQL queries running multiple times when the server is under a heavy load. 

Example, if I do an 'update Table1 set item1 = 0 where 1 = 1'

This runs fine under normal conditions, but will repeat itself multiple times when the server is under load.  Is this just an optimization or server resource issue.  If so, I would assume the query would just timeout and not run at all instead of running a few times.

View Replies !
POP Account Creation Script On CPanel. Runs Fine On Win2000, Not On Linux.
I am facing a weird problem. This is a POP account creation script. If I run it from my Win2000 PC, it creates the POP account. But when I run this script from the Linux server (CPanel is also on that server), it does not create any POP account.

View Replies !
Working With Dates - Runs And Queries The Database To Produce A List Of Information
I have a script that runs and queries the database to produce a list of information, based on a date range. This is to fllow up on a script that is automatically run each Sunday night.

What I want to try and acheive is, for example, if someone manually runs this report on a Tuesday the script will assume that it is run on the Sunday night, to make sure the results are exactly the same as the emails that have gone out. PHP Code:

View Replies !
How Many Connections Can You Have ?
Currently, I need to connect to 4 different databases on one page to extract information. But 1 of the 4 connections isnt working, is there a limit of 3 connections or something?

View Replies !
Allow Only 2 Connections Per Ip
i was wondering how i would prevent my users from downloading more than 2 files at a time in a single directory. for example ==>

yoursite.com/downloads/movies/index?file=blah.avi the yoursite.com/downloads/movies/ would be the directory i would want to be prevented from downloading more than 2 files.

is there a way to do this with an .htaccess file? or a simple php script?

View Replies !
Too Many Connections
Occasionally on my website I will get this message appearing "Too many connections" where there is php code. On all of my php pages I am accessing a db but I dont have the mysql_close syntax. Is this causing this message?

View Replies !
Php & Postgre Connections
I know this sounds a bit backwards, but i've got to port some scripts from mysql to postgre, but at the moment i don't have a postgre setup i can test on, sooooo can anyone tell me if this is the right way to connect.....

$Connx_Id = pg_connect($Host_Name, $Port, , , $DBName);

or is it.....

$Connx_Id = pg_connect(host='$Host_Name', port='$Port', dbname='$DBName');

Also does postgre require a port or does it default to a standard if not specified like mysql defaults to 3306?

View Replies !
Closing Connections?
I know alot of people are probably getting tired of the mysq_(p)connect questions, but I could not find an answer anywhere else.

If I run multiple queries in a page and parse HTML inbetween them, should I close the connections inbetween the queries (using mysql_connect()) or should I just let it be until the script is finished?

View Replies !
Persistent Connections
I just started coding with PHP a few days ago. My code interfaces with a simple database of the books I own. MySQL is running on my computer, and Apache/PHP is running on another.

I tried using persistent connections to lessen the overhead of opening the TCP connection etc, but when I reload the page multiple times, PHP seems to make a new connection for each reload. I checked the processlist in MySQL and I had a whole bunch of sleeping connections from the webserver.

So my question is... did I do something wrong? I basically just changed from connect to pconnect... and to test it I was just reloading the page, so it was using the same username and password for the database.

Also, another question... how do I turn on compression when connecting to MySQL from a .php file? I don't have root access to the Apache machine.

View Replies !
Getting DB Errors For Too Many Connections.
about twice a day, i've been getting DB errors for too many connections.

can someone walk me through how to change this value? the mysql info on
it is pretty mimimal.

i'm on cpanel/WHM and have SSH access to my box.

View Replies !
PHP Database Connections
I am trying to develop a web site on a development machine that needs to access data in a mysql database.

I have mysql running on my development machine with a copy of the database. While developing the app. I can connect to the local version of the database
without problems. Once I upload the database to its host site I need
to change the php scripts that connect to the database to refelect the
appropriate connection associated with the hosting server. Does
anyone know of an efficient way to have my script test for which
location it is on and connect to the appropriate mysql database? Or,
does anyone know of a php script that can handle this programmatically?

View Replies !
Too Many Connections To PostgreSQL
I'm running into a problem wherein I'm unable to connect to my postgresql db because the maximum number of connections has been reached. I use ADOdb for my db work, and the thing is I'm using the PConnect function, so it's supposed to be using persistent connections.

Since this is the case, I find it very strange that I'm having problems with the number of connections to postgresql. Also, I'm the only one using Postgresql on this server (a test machine) and I'm working on one area of my project (two or three pages) so it should definitely be reusing the connections.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved