TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-27-2008, 12:36 PM   #1 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Help why do not p in mysql_connect work?

i get Fatal error: Call to undefined function pmysql_connect() on line 6

$connection = mysql_pconnect('localhost', 'name', 'pass');

Why do i get the error?..

EDIT: lol i put in the wrong place xD

Last edited by codefreek : 06-27-2008 at 12:40 PM. Reason: Fixed
codefreek is offline  
Reply With Quote
Old 06-27-2008, 02:51 PM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by codefreek View Post
i get Fatal error: Call to undefined function pmysql_connect() on line 6

$connection = mysql_pconnect('localhost', 'name', 'pass');

Why do i get the error?..

EDIT: lol i put in the wrong place xD
That function means connected persistantly, as I do not understand it between the normal function.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
The Following User Says Thank You to Orc For This Useful Post:
codefreek (06-27-2008)
Old 06-27-2008, 03:07 PM   #3 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Basically there are some major differences:
  1. mysql_pconnect creates a 'persistent' connection therefore the link to the database is always open, mysql_connect however isnt like that and its links are closed when the script finishes and therefore must be reopened.
  2. mysql_pconnect searches for exisiting persistent connections ans re-uses them if they are found, mysql_connect on the other hand, does not.
  3. Links created with mysql_pconnect cannot be closed with mysql_close
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)

Last edited by sketchMedia : 06-28-2008 at 01:58 PM. Reason: added 'persistent' to clarify my point
sketchMedia is offline  
Reply With Quote
The Following User Says Thank You to sketchMedia For This Useful Post:
codefreek (06-27-2008)
Old 06-27-2008, 07:05 PM   #4 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

You are wrong about #2.

Quote:
Originally Posted by php.net
mysql_connect description on php.net:

Opens or reuses a connection to a MySQL server.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
The Following User Says Thank You to xenon For This Useful Post:
codefreek (06-27-2008)
Old 06-27-2008, 07:17 PM   #5 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

Guys, i know what it do that's why i am using it ;)
but thank you ;)
codefreek is offline  
Reply With Quote
Old 06-28-2008, 01:56 PM   #6 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Quote:
You are wrong about #2.
I dont think i am, i am fully aware that mysql_connect reuses a connection, but i was referring to the connections after the page has finished executing (known as persistent) that are still open. Logically if you open a connection with mysql_connect when the code finishes it closes the connection as it isn't persistent, therefore if you then run he script again it must create a new connection thus my statement is correct. Notice that the manual also says:
" If a second call is made to mysql_connect() " indicting a call to this function in the same script execution.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:55 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design