Solved

PHP , SQL Connection And Recordset

Posted on 2008-06-12
9
696 Views
Last Modified: 2013-12-13
Hi Guys

im having some problems with my intranet system that im trying to develop. My Problem is that the Database part in PHP crashes my IIS somehow. I cant se anything in the IIS log when it happens. the php.log doesnt say anything worth mentioning. What happens is that when you've used the intranet a little while, you cant talk to the database anylonger until you restart IIS. then it works perfectly again. Anyone have an idear what could cause this? Im running PHP 4 on IIS to an MS SQL Server

I also have some other questions..

1)
how come when i want to $rs->Close a recordset that just executes an insert or update statement that it says the object is allready closed? is that because you only have to do a $rs->Close on SELECT querys?

2)
if i do a select from a database $rs = $conn->execute($select), and then i want to do another select for something else  afterwords.. do i have to $rs->Close the first one before doing a $rs = $conn->execute($select) ? could that have something to do with my crash problem if im not doing that?

3)
Is there a way to see how many connections i have to my database server?

Thanks
0
Comment
Question by:tim_carter
  • 5
  • 3
9 Comments
 
LVL 1

Author Comment

by:tim_carter
ID: 21777170
No one that has an idea to this? thanks
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21782987
when you run a INSERT/UPDATE/DELETE, you won't get a recordset back, and actually should not expect a recordset.
you will get a empty/closed recordset indeed, as the error message tells.

so, for anything that is not a SELECT:
$rs = $conn->execute($select);
should be replaced by
$conn->execute($select);

or, $rs ignored.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 21784221
>>> 3) Is there a way to see how many connections i have to my database server?

On the server, use this command:

mysqladmin processlist
0
 
LVL 1

Author Comment

by:tim_carter
ID: 21784878
Angelll. ahh because im not getting anything back i dont have to put a recordset into a var.. of course.. But can it cause performance problems to do so? i mean could that be a cause to my problem?

routinet : im running MSSQL how do i do it there?
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21784889
>But can it cause performance problems to do so?
no

>2)
>if i do a select from a database $rs = $conn->execute($select), and then i want to do another select for something else  afterwords.. do i >have to $rs->Close the first one before doing a $rs = $conn->execute($select) ? could that have something to do with my crash problem if >im not doing that?

you should close a recordset (ie any object) once you used it, to clean up the resources.

3) Is there a way to see how many connections i have to my database server?
in ms sql sever:
select * from master.dbo.sysprocesses
0
 
LVL 1

Author Closing Comment

by:tim_carter
ID: 31467183
Thanks Angellll your the best
0
 
LVL 1

Author Comment

by:tim_carter
ID: 21785341
Angelll

I connect with ADODB SQL. is that the best way ? or would it be better to use mssql_connect in php?

Thanks
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 21785357
both ADODB and mssql have a object tier to access the database, ie both are just fine.
the ADODB is more for people coming from the VB world, the mssql.xxxx functions is more for the people coming from the mysql.xxxx functions worlds...
0
 
LVL 1

Author Comment

by:tim_carter
ID: 21791193
Thank you Angellll. I will continue using adodb. I just hope that i can find my error. Its really irritating that it crashes my IIS sometimes
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now