Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Three Part Question

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Three Part Question

Postby elitecodex » Mon Jul 29, 2002 6:24 am

I actually have three questions, all regarding to PHP & mySQL, but three different areas. This could be three seperate topics, but I figured that posting all at once would make things a little easier for everyone.

QUESTION 1:
---------------
Upon reading the manual, I cannot find a difference between mysql_connect() and mysql_pconnect() other than that pconnect opens up a "persistant" connection. What does that mean? Whats the difference between opening a "regular" connection and a "persistant" connection?

QUESTON 2:
--------------
When accessing a mysql database, and using information from different tables within many different functions across different files; would it be better to have one global connection and declare the resource global in each function or open/close the database as needed per function. I would think that one global variable would do it, but does that pose any drawbacks?

QUESTION 3:
---------------
I dont remember if I have asked this question before or not, but im still having problems so ill ask again. My apoligies if this is a repost. I have a call to mysql_query() and the " or die(mysql_error());" clause at the end of it. Now, the script does stop, however, it does not output an error. I have outputted the sql statement, and it is valid (or at least as far as I can see). I do pass in a globally declared connection resource (which works throughout other query calls). How can I figure out the cause of the problem with no error message?

Sorry for the mix of questions, but I got kinda confused and could not find the information I was looking for inside of the manual or on the net. Thanks for any help in advance.

Will
elitecodex
New php-forum User
New php-forum User
 
Posts: 68
Joined: Tue Jul 09, 2002 8:45 am
Location: East Coast, USA

Re: Three Part Question

Postby WiZARD » Wed Jul 31, 2002 4:07 am

elitecodex wrote:I actually have three questions, all regarding to PHP & mySQL, but three different areas. This could be three seperate topics, but I figured that posting all at once would make things a little easier for everyone.

QUESTION 1:
---------------
Upon reading the manual, I cannot find a difference between mysql_connect() and mysql_pconnect() other than that pconnect opens up a "persistant" connection. What does that mean? Whats the difference between opening a "regular" connection and a "persistant" connection?

QUESTON 2:
--------------
When accessing a mysql database, and using information from different tables within many different functions across different files; would it be better to have one global connection and declare the resource global in each function or open/close the database as needed per function. I would think that one global variable would do it, but does that pose any drawbacks?

QUESTION 3:
---------------
I dont remember if I have asked this question before or not, but im still having problems so ill ask again. My apoligies if this is a repost. I have a call to mysql_query() and the " or die(mysql_error());" clause at the end of it. Now, the script does stop, however, it does not output an error. I have outputted the sql statement, and it is valid (or at least as far as I can see). I do pass in a globally declared connection resource (which works throughout other query calls). How can I figure out the cause of the problem with no error message?

Sorry for the mix of questions, but I got kinda confused and could not find the information I was looking for inside of the manual or on the net. Thanks for any help in advance.

Will

Hi Will!
I'm not sure, but I'm try answer at your's question:
1
Your asked what different between mysql_connect() and mysql_connect(). That's very simple:
Than you using mysql_connect() in php script you connect to DB and terminate this connection after script finished. In mysql_pcconnect() after end script connection not terminate. It's create for high speed than mach more peaple using your site.
2
You can (if you want) create class, or use checking workin class for manage connection and operate records.
3
This most best use than you connecting to DB not to query.Why???
User avatar
WiZARD
Moderator
Moderator
 
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.