Jump to content

Problem for mysql PDO

- - - - -

  • Please log in to reply
5 replies to this topic

#1
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
hi guys

i use mysql pdo for connect to database

but Sometimes i see this error: General error: 2006 MySQL server has gone away


why?

thank you

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Hello,

Are you running the database on a shared server, localhost, or on your own dedicated server? If it is a shared server, it may very well point to a misconfiguration and it would make sense to contact the support area if your code is not at fault.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Hello,

Thank you for reply

ye in the share server and my web site is very slow, but with mysql function is normally speed for view page

please give me more information, i have access to change php.ini

---------- Post added at 11:16 AM ---------- Previous post was at 09:58 AM ----------

My support center is said:
You would need to check with your developer or probably optimize your site code in this case.
However there is nothing in addition that we can do if there is problem with the resolution because all servers have same standard where the hosting package is located.

___________________________

this is my connection code:

	public function sqlConnection()

	{

		try

		{

			self::$dbConnect = new PDO("mysql:host=" . self::$dbHost . ";port=" . self::$dbPort . ";dbname=" . self::$dbName, 

										self::$dbUsername, 

										self::$dbPassword, array(

																	PDO::ATTR_PERSISTENT => false,

																	PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"

																));


			self::$dbConnect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

		}

		catch(PDOException $e)

		{

			throw new databaseException($e->getMessage(), 102);

		}

	}



#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
I can see nothing in that specific code block that would hang the server. It is a small request too at that.

Where is the MySQL server hosted? Where is $dbHost, hosted on the exact same server or elsewhere? If your host is making you connect to an external server then it may be too slow to connect to, and there is not much you can optimise. It may also point to an issue with PDO, as it is a binary driver within PHP usually however that may be pushing it.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
host in internal server
and i use localhost

help more for this problem

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200

lol33d said:

host in internal server
and i use localhost

help more for this problem

Does this issue occur when you use standard MySQL code to connect to the database? Unless you are using code that you have not shown us that may be breaking the connection with the MySQL host it is entirely possible the host is at fault.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users