Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 04-24-2005, 11:29 AM   #1
Steen2
Confirmed User
 
Join Date: Feb 2004
Location: Vancouver, Canada
Posts: 7,662
Does this PHP code look OK?

PHP Code:
    function mysqlconn() {
         
$user "DB_DB";
         
$pass "pass";
         
$db "DB_DB";
         
$newconnect mysql_pconnect(localhost$user,$pass) or die(mysql_error());
         
mysql_select_db($db) or die(mysql_error());
         if(
mysql_error()) { echo mysql_error(); }
    } 
It's causing this error in my error logs and looks to be hurting the server: PHP Warning: mysql_pconnect(): Link to server lost, unable to reconnect in ...

The line the error references is
$user = "DB_DB";

But I included the lines around it for better insight.
__________________
ICQ: 2262.73945
Steen2 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 11:38 AM   #2
ssp
Confirmed User
 
Join Date: Jan 2005
Location: United Kingdom
Posts: 7,990
Have you tried using all lower cases in your username?
ssp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 11:42 AM   #3
Steen2
Confirmed User
 
Join Date: Feb 2004
Location: Vancouver, Canada
Posts: 7,662
Quote:
Originally Posted by ssp
Have you tried using all lower cases in your username?
Sorry?

"DB_DB" is to edit out information that's "sensitive".
__________________
ICQ: 2262.73945
Steen2 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 11:44 AM   #4
ssp
Confirmed User
 
Join Date: Jan 2005
Location: United Kingdom
Posts: 7,990
Perhaps it's because there is a space in this line:

mysql_pconnect(localhost, $user,$pass)
ssp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 11:52 AM   #5
Calvinguy
Confirmed User
 
Join Date: Oct 2002
Location: European Union
Posts: 1,752
Try to use single qoutes ' rather then doubleqoutes "


or put qoutes around localhost also...
Calvinguy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 12:14 PM   #6
Steen2
Confirmed User
 
Join Date: Feb 2004
Location: Vancouver, Canada
Posts: 7,662
Quote:
Originally Posted by ssp
Perhaps it's because there is a space in this line:

mysql_pconnect(localhost, $user,$pass)
Quote:
Try to use single qoutes ' rather then doubleqoutes "


or put qoutes around localhost also...
Thanks, but would this crash the server's mysql?
__________________
ICQ: 2262.73945
Steen2 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 12:23 PM   #7
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
put localhost in single qoutes
whitespace such as spaces, tabs, etc in code is ignored

seems there s a prob with connection rather than anything else at this point
i've never used mysql_pconnect, see if mysql_connect works better for you.
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 12:26 PM   #8
Nysus
Confirmed User
 
Industry Role:
Join Date: Aug 2001
Posts: 7,817
Hope you're putting that function in an include file as opposed to on a page, or have multiple DBs at different locations to use... you only need to connect to a mySQL server once each load.

Matt
Nysus is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 12:28 PM   #9
who
So Fucking Banned
 
Join Date: Aug 2003
Location: ICQ #23642053
Posts: 19,593
Is your username the same as the database name?
who is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 12:28 PM   #10
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
here is a good sample for you from php manual:

Code:
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password') or die (mysql_error());
db_selected = mysql_select_db('db_name', $link) or die (mysql_error());
or die() is not recommended for use in live production.
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 04-24-2005, 12:34 PM   #11
Serge Litehead
Confirmed User
 
Serge Litehead's Avatar
 
Industry Role:
Join Date: Dec 2002
Location: Behind the scenes
Posts: 5,190
err in above post

db_selected = $db_selected
__________________
Serge Litehead is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.