Jump to content


MySQL Class Help


4 replies to this topic

#1 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 06 May 2007 - 03:53 PM

I've been tweaking this class I have been using to work better with PHP5 so it doesn't get any warnings or notices in the error log file. I've gotten pretty much all of them except for one.

Quote

PHP Warning: mysql_ping(): 7 is not a valid MySQL-Link resource in ****/public_html/test/mysql.php on line 69

Source


Line 69 is the "IF"
	function __destruct() {
		//----------------------------------------------
		// check for a connection to mysql and close it
		//----------------------------------------------
		if (mysql_ping($this->connection)) { mysql_close($this->connection); }
		return true;
	}

Edited by SpatialVisionary, 06 May 2007 - 05:26 PM.


#2 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 06 May 2007 - 04:26 PM

Ugh, I've had a similar problem and I can't remember how I fixed it!

All I know, is that I simply check whether the connection ID exists before I close it. I don't see why a ping wouldn't work though. =\

I like your class though, has a completely different implication than I've seen, lol. :P

#3 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 06 May 2007 - 04:28 PM

View PostDemonslay, on May 6 2007, 04:26 PM, said:

Ugh, I've had a similar problem and I can't remember how I fixed it!

All I know, is that I simply check whether the connection ID exists before I close it. I don't see why a ping wouldn't work though. =\

I like your class though, has a completely different implication than I've seen, lol. ;)

yeah, i found it through a tutorial here. didn't really care for it as it was and tweaked it.

was working great in PHP4 then I decided to switch to PHP5 and started getting notices and warnings.


btw. i get the same error if i remove the mysql_ping and just have it immediately do the mysql_close.

except for the fact 'mysql_ping' is replaced with 'mysql_close' :censored:

Edited by SpatialVisionary, 06 May 2007 - 04:30 PM.


#4 Pixel Prestige

    Young Padawan

  • Members
  • Pip
  • 41 posts
  • Gender:Male
  • Location:Houston, TX
  • Interests:Programming<br />Development<br />Design

Posted 06 May 2007 - 06:37 PM

SpatialVisionary,
You said PHP5 yes? Perhaps this quote I found would be a little help.

Quote

if mysql server is 5.0.13 and later, mysql client MUST set option
"MYSQL_OPT_RECONNECT" to TRUE, then mysql_ping will work.
http://dev.mysql.com...ql-options.html

Good Luck :censored:

#5 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 06 May 2007 - 07:02 PM

View PostPixel Prestige, on May 6 2007, 06:37 PM, said:

SpatialVisionary,
You said PHP5 yes? Perhaps this quote I found would be a little help.

Quote

if mysql server is 5.0.13 and later, mysql client MUST set option
"MYSQL_OPT_RECONNECT" to TRUE, then mysql_ping will work.
http://dev.mysql.com...ql-options.html

Good Luck :censored:

thanks. i think you hit nail on the head.

got to thinking, so i ran a phpinfo() and noticed the mysql reconnect setting.
[attachment=2774:mysql.jpg]





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users