ขอความช่วยเหลือครับ mysql_connect() [function.mysql-connect]

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderators: mindphp, ผู้ดูแลกระดาน

bigmac

ขอความช่วยเหลือครับ mysql_connect() [function.mysql-connect]

Post by bigmac »

Warning: mysql_connect() [function.mysql-connect]: Too many connections in /home/tsl.co.th/public_html/libs/connect.php on line 4
Not connected : Too many connections

ช่วยด้วยครับมันขึ้นข้อความแบบนี้อะครับ ต้องแก้ไขยังไง ขอแบบละเอียดหน่อยครับ งง รีสตาร์แล้ว เว็บเปิดได้ พอมีคนเข้ามาดูสักปริมาณนึง หน้าเว็บก็ขึ้น แบบนี้ แล้วก็เข้าไม่ได้ ครับ
ขอบคุณ
อันนี้ code ของ connect.php

<?
function open_db()
{
$conn = mysql_connect(DB_SERVER,DB_USER,DB_PWD);
if (!$conn)
die('Not connected : ' . mysql_error());

$db_selected = mysql_select_db(DB_NAME,$conn);
if (!$db_selected)
die ('Can\'t use '.DB_NAME.': ' . mysql_error());
mysql_query("set names utf8");
require_once("db.class.php");
return $conn;
}

function close_db($conn)
{
if($conn!=null) {
mysql_close($conn);
}
}

function to_valid_sql($sql)
{
if ($_SERVER["SERVER_NAME"]=="localhost") {
$valid_sql = str_replace("'","''",$sql);
}
else {
$valid_sql = $sql;
}
return $valid_sql;
}

function to_valid_fload($sql)
{
$valid_sql = str_replace(",","",$sql);
return $valid_sql;
}

function convert_post_data($value)
{
if ($_SERVER["SERVER_NAME"]=="localhost") {
$convert_data = $value;
}
else
{
$convert_data = str_replace("\'","'",$value);
$convert_data = str_replace("\\\\","\\",$convert_data);
}
}

function convert_html_data($value)
{
$convert_data = htmlspecialchars($value); //Convertfrom html to character
return $convert_data;
}

function convert_date($value)
{
if($value!='' and $value!='0000-00-00') {
$val = new date_format($value);
$value = $val->convert_format('dmy','/');
} else {
$value = '';
}
return $value;
}

function convert_read_date($value,$type)
{
if($value!='' and $value!='0000-00-00') {
$val = new date_format($value);
$value = $val->read_date($type);
} else {
$value = '';
}
return $value;
}


function convert_basedate($value)
{
if($value!='') {
$val = new date_format($value,'onlyday');
$value = $val->datetime;
} else {
$value = '';
}
return $value;
}

function convert_nowdate()
{
$val = new date_format('','');
$value = $val->pdate;
return $value;
}

function convert_nowyear()
{
$val = new date_format('','');
$value = $val->year;
return $value;
}

function convert_nowtimestemp($value,$type)
{
if($type=='1') { // date
$val = new date_format($value,'onlyday');
$value = $val->time_stamp;
} elseif($type=='2') { // datetime
$val = new date_format($value,'mysql');
$value = $val->time_stamp;
} else {
$val = new date_format('','');
$value = $val->time_stamp;
}
return $value;
}

function txt_process($process)
{
switch ($process)
{

case 1:
$msg = 'The information has been saved. <a href="'.$PHP_SELF.'">Add More</a>';
break;

case 2:
$msg = 'The information has been updated.';
break;

case 3:
$msg = 'The information has been deleted.';
break;

case 4:
$msg = 'The information can not be deleted, Because Associated with each of the data.';
break;

case 5:
$msg = 'File has been uploaded.';
break;

case 6:
$msg = 'File cannot copy to server.';
break;

case 7:
$msg = 'Incorrect file format.';
break;

case 8:
$msg = 'File not found.';
break;

case 9:
$msg = ' The information has been added to the stock.';
break;

case 10:
$msg = ' The information has been canceled.';
break;

case 0:
$msg = '';
break;

}
return $msg;
}

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}



?>
  • Similar Topics
    Replies
    Views
    Last post

Return to “Programming - PHP”

Who is online

Users browsing this forum: Bing [Bot] and 23 guests