I have a problem with mysql connection.
I have a php script which upload photo, this script do that:
1) mysql connection
2) check user rights for uploading photo (I use a sql query for this)
3) Image processing
4) sql query for insering photo data in database
I have set a mysql connection timeout to 5 s.
Everything works great if the image processing time is less than 5s (mysql connection timeout) otherwise I got a error when the step 4) is executed, the error is "Mysql server has gone away".
So, I checked if the mysql connection was still alive after the image processing and the mysql connection died if the image processing time is more then 5s.
I added this code after the image processing (step 3)
if(!mysql_ping($conn)){
$conn = mysql_connect('localhost', 'mysqluser', 'mypass');
$db = mysql_select_db('mydb',$conn);
}
but it doesn't work! this is my real problem.
var_dump($conn)
give a mysql ressource link but
mysql_select_db('mydb',$conn)
return FALSE, and mysql_error()
return "mysql server has gone away"
Does anybody can help me?
Thanks in advance.
Quote from http://dev.mysql.com/doc/refman/5.0/en/gone-away.html:
etc.