Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 02-03-2006, 09:49 PM   #1
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
PHP queries

This may be a dumb question, but I'll ask anyway. If you have more than 1 query in a PHP script do you need to use mysql_close() after each query or only have 1 mysql_close at the end of the page?

One other thing, can I do more than 1 query each time I connect to the database? I have a number of queries on a page I'm working on and I'm trying to speed up the load time by combining queries.

TIA
__________________
Eric
Help save lives! Click Here
AMD 4800+ X2 @ 2750Mhz (250 x 11) | DFI LanParty UT CFX3200 | 2GB Mushkin pc4000 3-3-2-8 1:1
Sapphire X1900GT 256MB | (2) 150GB Raptors RAID0 | WD 320GB
enhanced08 is offline   Reply With Quote
Old 02-03-2006, 10:02 PM   #2
Member (7 bit)
 
Join Date: Dec 2005
Posts: 87
If you are doing insert queries it is recommended you seperate each query with a semi-colon and run the entire string:

$query='INSERT INTO test1 VALUES("a","b","c");INSERT INTO test2 VALUES("1","2","3")';
$result=mysql_query($query);

I believe the connection to the database is made with the mysql_query command. The connection for mysql_connect and mysql_db_select aren't made with those commands I believe.

If you were doing select queries where you had to get a value out of it you would have to have two different mysql_result commands although it isn't recommended. Try to use a different approach so you only have one query, whether it is in your script our database structure.

My experience with optimization is that bandwidth is the major bottleneck. MySQL queries are next but only appear if you have really bad design. PHP is a distant third and they only slow the page down if you are reading an external file.

I would first say check the image size of your pictures if it is loading slow.
hartken is offline   Reply With Quote
Old 02-03-2006, 10:13 PM   #3
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
Well the images are the same on every page so thats not the problem. I deleted all the mysql_connect scripts out except for the first and that seems to have helped a lot, I have something like 20 queries on this page so in doing this it helped a lot.
enhanced08 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

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



All times are GMT -5. The time now is 05:04 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2