FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
Access Violation
Message  

Reply with quote
Post Access Violation 
Hi,

I'm getting the error

"PHP has encountered an Access Violation at XXXXXXX..."

with a site I'm working on.

It happens on occasion when I load a page but not all of the time.

Is this is a problem with my code or is it a problem with my web server?

Cheers.

View user's profile Send private message

Reply with quote
Post  
Does it say the error was on a line? Or just say access violation? Are you sure that your host has php enables?

View user's profile Send private message

Reply with quote
Post  
The message seems to have actually gone now.

Everything was fine for days then suddenly the server seemed to come down and when it came back up, I was getting that Access Violation at random points in the site.

I'm assuming that since it's gone away, it was a problem on the hosting company's end.

Cheers.

View user's profile Send private message

Reply with quote
Post  
It sounds like more of a server problem than a code problem..  can you post the PHP script that was giving you this error?

View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger

Reply with quote
Post  
It was quite a large site but it started happening after I created a class and instantiated it on a page like this:

include('resource/include/global.php');
include('resource/include/page.php');

$page = new page($_GET['section'], $_GET['page'], $db);

echo $page->title;

etc.

The $db varaible is my PEAR db connection.

I thought it might have something to do with the fact that many instances of the object were being created but I wasn't destroying them.

Cheers.

View user's profile Send private message

Reply with quote
Post  
Yeah that could definitely do it.  The server probably ran out of data memory space for these objects if you do not destroy them properly.

View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger

Reply with quote
Post  
How do I destroy an object properly?

Currently I have the function:

        function destroy()
  {
           settype(&$this, 'null');
      }

Would this do it? Would I just call this at the end of each my scripts?

I heard that the usual deconstructor was flawed and didn't always work properly.

Any ideas?

Cheers.

View user's profile Send private message

Reply with quote
Post  
You can just use the unset() variable just as any other variable.  So to delete the object named Object1 use

Code:

unset( Object1 );


The unset function will determine that it is an object and call the objects destructor function.

Hope that helps.

View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger

Reply with quote
Post  
Thanks for the help.

I've included a footer to make sure the page objects which I create are destroyed properly.

However, I've got a question about sessions and the use of objects within them.

I have a user login and authentication script set up. The authentication script checks the login details and, if they are correct, instantiates a user object with information about that user. The object is then made available through a session.

Code looks like this:

while( $row = $result->fetchrow(DB_FETCHMODE_ASSOC) )
{
    if($_POST['username']==$row[username] && $_POST['password']==$row[password])
    {
           $user = new user($row[user_id], $row[username], $row[password], $row[firstname], $row[surname], $row[department], $row[email]);
             $_SESSION['valid_user'] = $user;
  }              
}


When the user logs out, I destroy sessions using session_destroy() but as far as I'm aware, this won't unset the object variable will it?

Where do I do this? In the logout script or at the end of the authentication script once the session has been made?

Cheers.

View user's profile Send private message

Reply with quote
Post  
You would want to do this in the logout script.  What object are you talking about unsetting?  The $_SESSION array?  If so, you can use the unset() function to do this as well when the user logs out before you call session_destroy( ).

View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger

Reply with quote
Post  
Sorry, I mean destroying the $user instance I created in the script before putting it into the session.

Where do I kill that? In the script or when the user logs out?

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com