Wrox Programmer Forums
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2004, 11:04 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default open close db

When retreiving data from 2 or more tables, do you need to open and close each query with
Code:
mysql_close($connection);
??

I have a 3rd table that is unable to match the data from a correct SQL statement that I have tested on it own.



Michael.
__________________
Michael.
 
Old July 19th, 2004, 11:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nope.

In fact, you don't _need_ to call mysql_close() at all. PHP's garbage collector handles all that for you on finishing each page/script/whatever. Not using mysql_close() just seems like the RAM-equivalent of fly-tipping, though, so people tend to use it.
 
Old July 19th, 2004, 11:43 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

:) Hi Daniel,

I thought so.
From the previous query that I posted, I am now trying to call the id from manufacturers using the prod_id, using this statement;

Code:
SELECT * FROM manufacturers WHERE manufacturers_id = '$prod_id'
This works in SQL command but for some reason when calling from the main PHP page it falls into my error catch and outputs saying that there is not data in the manufacturers table.

The entire PHP is working still but not this bit...

Michael.
 
Old July 19th, 2004, 11:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First thing to try, then, is echo the query out in the browser immediately before you try and execute it. Even if it's not immediately apparent what's afoot, you can then cut&paste the query into the DB directly and see what it says to you. You retrieve the value of $prod_id from the $_POST array before using it in the query with something along the lines of: "$prod_id = $_POST['prod_id']", do you?

Either way, you can bet your boots it's not doing what you expect it to because it's doing exactly what you're telling it to. All you really have to do is work out what you are asking it to do, and all will be clear.

Dan





Similar Threads
Thread Thread Starter Forum Replies Last Post
Tip: How to open/close CDROM automatically crmpicco Javascript How-To 3 April 9th, 2008 05:30 AM
Open/Close Multiple Forms dzisaacs C# 2 August 20th, 2006 05:25 PM
asp can't open db when db open by other program datuk Classic ASP Professional 3 June 13th, 2006 06:10 PM
I can open a new window but can't close it camelius ASP.NET 2.0 Basics 0 March 16th, 2006 06:26 AM
Open and close windows skicrud Javascript How-To 1 August 17th, 2004 04:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.